angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

`ng build --prod` crashes after upgrade to v7

Open maxime1992 opened this issue 8 years ago • 6 comments

Bug Report or Feature Request (mark with an x)

- [ x ] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ x ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 7.0.2
Node: 10.0.0
OS: linux x64
Angular: 7.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... http, language-service, material, platform-browser
... platform-browser-dynamic, platform-server, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.10.2
@angular-devkit/build-angular      0.10.2
@angular-devkit/build-ng-packagr   0.10.2
@angular-devkit/build-optimizer    0.10.2
@angular-devkit/build-webpack      0.10.2
@angular-devkit/core               7.0.2
@angular-devkit/schematics         7.0.2
@angular/cli                       7.0.2
@angular/flex-layout               7.0.0-beta.19
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.0.2
@schematics/angular                7.0.2
@schematics/update                 0.10.2
ng-packagr                         4.4.0
rxjs                               6.3.3
typescript                         3.1.3
webpack                            4.19.1

Issue

Upgrading to the latest version (7) I am not able to build my project locally (Linux, ubuntu 64bits, 32gb RAM) nor... on CI :crying_cat_face:

The log given by the failure

yarn run build:browser
yarn run v1.6.0
(node:142) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ ng build frontend --prod --source-map false

<--- Last few GCs --->

[163:0x3dd8270]   617339 ms: Mark-sweep 1332.2 (1447.7) -> 1332.2 (1447.7) MB, 1465.5 / 0.0 ms  allocation failure GC in old space requested
[163:0x3dd8270]   618828 ms: Mark-sweep 1332.2 (1447.7) -> 1332.2 (1431.7) MB, 1488.5 / 0.0 ms  last resort GC in old space requested
[163:0x3dd8270]   620307 ms: Mark-sweep 1332.2 (1431.7) -> 1332.2 (1431.7) MB, 1478.9 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x30481308427d]
    1: StubFrame [pc: 0x3048130e8700]
Security context: 0x11ddf7a206a9 <JSObject>
    2: add_parameter [/builds/maxime1992/frontend/node_modules/terser/dist/bundle.js:2277] [bytecode=0xefb01b49349 offset=16](this=0x37561530ddc9 <Object map = 0x252dd083ea21>,token=0x37561530dfd1 <AST_Token map = 0x252dd083f061>)
    3: binding_element(aka binding_element) [/builds/maxime1992/frontend/node_modules/terse...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [ng build frontend --prod --source-map false]
 2: 0x87b56c [ng build frontend --prod --source-map false]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [ng build frontend --prod --source-map false]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ng build frontend --prod --source-map false]
 5: v8::internal::Factory::NewInternalizedStringImpl(v8::internal::Handle<v8::internal::String>, int, unsigned int) [ng build frontend --prod --source-map false]
 6: v8::internal::InternalizedStringKey::AsHandle(v8::internal::Isolate*) [ng build frontend --prod --source-map false]
 7: v8::internal::StringTable::LookupKey(v8::internal::Isolate*, v8::internal::StringTableKey*) [ng build frontend --prod --source-map false]
 8: v8::internal::StringTable::LookupString(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>) [ng build frontend --prod --source-map false]
 9: 0x10ce5cb [ng build frontend --prod --source-map false]
10: v8::internal::Runtime_KeyedGetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [ng build frontend --prod --source-map false]
11: 0x30481308427d
Aborted (core dumped)
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Job failed: exit code 1

Mention any other details that might be useful

Seems that the culprit might be Terser... Eventually that might be related to https://github.com/angular/angular-cli/issues/12646 but I'm not sure

Also, the compilation is fine without the --prod

maxime1992 avatar Oct 24 '18 12:10 maxime1992

I think the difference between v6 and v7 is the bug reported in #12646 as in that issue production builds are taking longer, which usually indicated that more code is being processed and more memory is needed.

The general issue for running out of memory is #5618. As projects grow bigger, they use more memory, and might need to increase the default memory limit. There's more information on this in #5618 (comment).

In your case the only thing you did was to update from v6 to v7 and it should not need significantly more memory than before. I'll look at that problem in #12646.

alan-agius4 avatar Oct 24 '18 12:10 alan-agius4

This has been changed in angular 7 now. I couldn't able to find the path of ng.. Please any help for finding its path in node modules..

`> node --max_old_space_size=5048 ng build --prod --aot --source-map=false

module.js:540 throw err; ^

Error: Error: Cannot find module '/Users/work/ui/node_modules/@angular/cli/bin/ng' at Function.Module._resolveFilename (module.js:538:15) at Function.Module._load (module.js:468:25) at Function.Module.runMain (module.js:684:10) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build-script-a7: node --max_old_space_size=5048 ng build --prod --aot --source-map=false npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build-script-a7 script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/.npm/_logs/2019-01-28T08_13_45_344Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: npm run config -- --environment=prod && npm run build-script-a7 && npm run prod-server npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/.npm/_logs/2019-01-28T08_13_45_364Z-debug.log`

prudhvichitturi avatar Jan 28 '19 08:01 prudhvichitturi

ng build --configuration=production

ldragos1 avatar Apr 20 '19 20:04 ldragos1

I am facing the same issue, I migrated my project from Angular 4 to Angular 8 . The ng serve workss fine but ng serve --prod shows the same problem. I have used the increase-memory-limit but I face the same problem. Any other suggestion of what to do ?

kumaraditya1999 avatar Jul 04 '19 10:07 kumaraditya1999

I am facing the same issue, I migrated my project from Angular 4 to Angular 8 . The ng serve workss fine but ng serve --prod shows the same problem. I have used the increase-memory-limit but I face the same problem. Any other suggestion of what to do ?

Same problem here, with Angular 8: ERROR in scripts.1b7a06e3af869680274b.js from Terser Unexpected token: punc (:) [scripts.1b7a06e3af869680274b.js:14,3]

reinierkops avatar Jul 05 '19 12:07 reinierkops

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.