Build fails with --build-optimizer
I am using Angular CLI and ng2-toastr, the build works fine except for when I use the --build-optimizer flag.
"ng2-toastr": "^4.1.2",
"@angular/cli": "1.3.1",
"@angular/compiler-cli": "^4.2.4",
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",

chunk {0} main.af95a22ee70ee67f9fd4.bundle.js (main) 2.26 MB {4} [initial] [rendered] chunk {1} polyfills.dd0a6ac24744c13f6a12.bundle.js (polyfills) 100 kB {4} [initial] [rendered] chunk {2} scripts.8b7c632216ff8731a825.bundle.js (scripts) 176 kB {4} [initial] [rendered] chunk {3} styles.cd3ed6dffa757592f7ef.bundle.css (styles) 608 kB {4} [initial] [rendered] chunk {4} inline.6bf5103d9484632f7300.bundle.js (inline) 1.47 kB [entry] [rendered]
<--- Last few GCs --->
[38096:0000013ED7BE4760] 217893 ms: Mark-sweep 1536.8 (2180.9) -> 1536.7 (2148.9) MB, 373.7 / 0.0 ms last resort [38096:0000013ED7BE4760] 218262 ms: Mark-sweep 1536.7 (2148.9) -> 1536.7 (2148.9) MB, 369.6 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000003CC66F28799
2: fromString(aka fromString) [buffer.js:308] [bytecode=000001E2E1BDFBF1 offset=202](this=0000009202682311 ,string=000003ED43554941 <Very long string[209908987]>,encoding=000003CC66F386D1 <St ring[4]: utf8>) 4: from [buffer.js:173] [bytecode=000001E2E1BDF701 offset=11](this=0000031027EB4161 <JSFunction Buffer (sfi = 0000008032413041)>,value=000003ED43554941 <Very long string[... FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory npm ERR! code ELIFECYCLE npm ERR! errno 3 npm ERR! [email protected] build:devwstats:
ng build --environment=dev --prod --build-optimizer --no-sourcemap --aot --stats-jsonnpm ERR! Exit status 3
Try this:
node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --environment=dev --prod --build-optimizer --no-sourcemap --aot --stats-json
For more discussion see #5618
use --target=production
What version of @angular-devkit/build-optimizer is present in the project?
Can you try updating to the latest stable version of the CLI (1.5.0)?
Also, the --prod option is essentially an alias for --environment=production --target=production --aot --no-sourcemaps --extract-css --output-hashing=all (in 1.5 also --build-optimizer) with individually specified options overriding those.
The problem you are seeing is a memory problem. Like most things, using Build Optimizer uses memory. Your project must have been almost at the memory limit and using build optimizer pushed it over.
You can read more about memory problems in https://github.com/angular/angular-cli/issues/5618. I advise you to use the latest CLI (1.6.0 now) as that includes a lot of memory optimizations.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.