Skip to content

"RangeError: Invalid string length" when building --prod #8580

@jmls

Description

@jmls

Versions

   _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.5.3
Node: 8.8.1
OS: linux x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.5.3
@angular/flex-layout: 2.0.0-beta.11-b01c2d7
@angular/language-service: 4.4.6
@angular/material: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.3
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack-bundle-analyzer: 2.9.1
webpack: 3.8.1```

### Repro steps

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod --stats-json --aot

### Observed behavior

/code/myapp/node_modules/@angular/cli/tasks/build.js:55
fs.writeFileSync(path.resolve(this.project.root, outputPath, 'stats.json'), JSON.stringify(stats.toJson(), null, 2));
^

RangeError: Invalid string length
at JSON.stringify ()
at callback (/code/myapp/node_modules/@angular/cli/tasks/build.js:55:102)
at emitRecords.err (/code/myapp/node_modules/webpack/lib/Compiler.js:269:13)
at Compiler.emitRecords (/code/myapp/node_modules/webpack/lib/Compiler.js:375:38)
at emitAssets.err (/code/myapp/node_modules/webpack/lib/Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (/code/myapp/node_modules/webpack/lib/Compiler.js:368:12)
at next (/code/myapp/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/code/myapp/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at next (/code/myapp/node_modules/tapable/lib/Tapable.js:220:14)
at Compiler.compiler.plugin (/code/myapp/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:425:13)
at next (/code/myapp/node_modules/tapable/lib/Tapable.js:220:14)
at callback (/code/myapp/node_modules/copy-webpack-plugin/dist/index.js:125:17)
at Compiler. (/code/myapp/node_modules/copy-webpack-plugin/dist/index.js:151:13)
at Compiler.applyPluginsAsyncSeries1 (/code/myapp/node_modules/tapable/lib/Tapable.js:222:13)
at Compiler.afterEmit (/code/myapp/node_modules/webpack/lib/Compiler.js:365:9)
at require.forEach.err (/code/myapp/node_modules/webpack/lib/Compiler.js:354:15)


### Desired behavior
for the build to complete without error

### Mention any other details that might be useful (optional)
just before this happened, memory usage went to over 4gb. This is the output on the terminal:

Date: 2017-11-21T19:39:38.800Z
Hash: 6ed885f416d309dbf8a2
Time: 254657ms
chunk {0} main.916d81fb105bd0fbe053.bundle.js (main) 4.49 MB [initial] [rendered]
chunk {1} polyfills.7b75f0119f57d635b955.bundle.js (polyfills) 199 kB [initial] [rendered]
chunk {2} styles.a276c0e8aee93fbc154b.bundle.css (styles) 1.54 MB [initial] [rendered]
chunk {3} inline.8419e018fd791975b6fb.bundle.js (inline) 1.45 kB [entry] [rendered]
/home/jmls/development/rtb-dashboard/node_modules/@angular/cli/tasks/build.js:55
fs.writeFileSync(path.resolve(this.project.root, outputPath, 'stats.json'), JSON.stringify(stats.toJson(), null, 2));


Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenttype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions