Closed doorman02 closed 7 years ago
I am having this issue too. Maybe it is a leakage somewhere.
On the other hand, is there any way to increase the maximum RAM? I observed it crashed at around 1.5GB.
I don't think this is an issue with the starter. Can you open it in the optimize-js
We also need more information on how to reproduce it.
If I just clone the repo it doesn't happen...
This does not happen with the repo on its own. It will start to happen if we use it in a project, and the project grows to a certain degree. Note: npm run build:prod runs ok.
Is there a way to increase the maximum RAM for npm before run build:aot:prod?
node --max_old_space_size=4096
How do we run it with the npm command? node --max_old_space_size=4096 npm run build:aot:prod?
So I added this script to the package.json file
"myscript": "npm run build:aot:prod && node --max_old_space_size=4096"
and ran it like this
npm run myscript
But without luck still getting the heap out of memory error.
@pilgylis did you find a solution to this?
Tried various ways without any luck :(
How about splitting the aot build into multiple steps, for example, the first step is to generate the compile folder, and the second is to merge it?
I noticed that when the out of memory occured, the compile folder had been created. Can someone helps to create a command to continue from that?
Finally made it work!! check out: https://github.com/AngularClass/angular2-webpack-starter/pull/1491/files
Also I had to made the following changes in order to work on my machine:
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js", "webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js"
Wow, @pilgylis thanks a bunch :)
Hi, anybody can help me to resolve this mistake
when id run npm run:build:aot
it's throw a mistake
JavaScript heap out of memory
but when i use this resolvent it's also throw a mistake
like this
`
ERROR in ./~/extract-text-webpack-plugin/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/extract-text-webpack-plugin'
@ ./~/extract-text-webpack-plugin/index.js 5:9-22
@ ./config/webpack.prod.js
@ multi main
ERROR in ./~/html-webpack-plugin/index.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/html-webpack-plugin' @ ./~/html-webpack-plugin/index.js 3:9-22 @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/extract-text-webpack-plugin/loader.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/extract-text-webpack-plugin' @ ./~/extract-text-webpack-plugin/loader.js 5:9-22 @ ./~/extract-text-webpack-plugin/index.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/uglify-js/tools/node.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/uglify-js/tools' @ ./~/uglify-js/tools/node.js 8:9-22 @ (webpack)/lib/optimize/UglifyJsPlugin.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/assets-webpack-plugin/lib/output/createOutputWriter.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/assets-webpack-plugin/lib/output' @ ./~/assets-webpack-plugin/lib/output/createOutputWriter.js 3:9-22 @ ./~/assets-webpack-plugin/index.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/copy-webpack-plugin/dist/preProcessPattern.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/copy-webpack-plugin/dist' @ ./~/copy-webpack-plugin/dist/preProcessPattern.js 26:41-54 @ ./~/copy-webpack-plugin/dist/index.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/awesome-typescript-loader/dist/cache.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/awesome-typescript-loader/dist' @ ./~/awesome-typescript-loader/dist/cache.js 2:9-22 @ ./~/awesome-typescript-loader/dist/index.js @ ./~/awesome-typescript-loader/dist/entry.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/awesome-typescript-loader/dist/helpers.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/awesome-typescript-loader/dist' @ ./~/awesome-typescript-loader/dist/helpers.js 2:9-22 @ ./~/awesome-typescript-loader/dist/index.js @ ./~/awesome-typescript-loader/dist/entry.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/awesome-typescript-loader/dist/instance.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/awesome-typescript-loader/dist' @ ./~/awesome-typescript-loader/dist/instance.js 2:9-22 @ ./~/awesome-typescript-loader/dist/index.js @ ./~/awesome-typescript-loader/dist/entry.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in (webpack)/lib/node/NodeOutputFileSystem.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/webpack/lib/node' @ (webpack)/lib/node/NodeOutputFileSystem.js 5:9-22 @ (webpack)/lib/node/NodeEnvironmentPlugin.js @ (webpack)/lib/webpack.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/copy-webpack-plugin/dist/writeFile.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/copy-webpack-plugin/dist' @ ./~/copy-webpack-plugin/dist/writeFile.js 24:41-54 @ ./~/copy-webpack-plugin/dist/processPattern.js @ ./~/copy-webpack-plugin/dist/index.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/ngc-webpack/src/main.js Module parse failed: /Users/kunlun/Desktop/huala-system/node_modules/ngc-webpack/src/main.js Unexpected character '#' (1:0) You may need an appropriate loader to handle this file type. | #!/usr/bin/env node | "use strict"; | require('ts-node/register'); @ ./~/ngc-webpack/src/plugin.js 4:13-30 @ ./~/ngc-webpack/index.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in (webpack)/lib/NormalModule.js Module not found: Error: Can't resolve 'module' in '/Users/kunlun/Desktop/huala-system/node_modules/webpack/lib' @ (webpack)/lib/NormalModule.js 96:16-33 @ (webpack)/lib/NormalModuleFactory.js @ (webpack)/lib/Compiler.js @ (webpack)/lib/webpack.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/mkdirp/index.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/mkdirp' @ ./~/mkdirp/index.js 2:9-22 @ ./~/assets-webpack-plugin/lib/output/createOutputWriter.js @ ./~/assets-webpack-plugin/index.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in ./~/glob/glob.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/glob' @ ./~/glob/glob.js 43:9-22 @ ./~/copy-webpack-plugin/dist/processPattern.js @ ./~/copy-webpack-plugin/dist/index.js @ ./config/webpack.common.js @ ./config/webpack.prod.js @ multi main
ERROR in (webpack)/lib/node/NodeMainTemplateAsync.runtime.js Module not found: Error: Can't resolve 'fs' in '/Users/kunlun/Desktop/huala-system/node_modules/webpack/lib/node' @ (webpack)/lib/node/NodeMainTemplateAsync.runtime.js 9:2-15 25:3-16 @ (webpack)/lib/node/NodeMainTemplatePlugin.js @ (webpack)/lib/node/NodeTemplatePlugin.js @ (webpack)/lib/WebpackOptionsApply.js @ (webpack)/lib/webpack.js @ ./config/webpack.common.js @ ./config/webpack.prod.js `
I am experiencing the same issue. It works fine with AOT until the code base gets larger, then you will start experiencing memory problems. The proposed fix, https://github.com/AngularClass/angular2-webpack-starter/pull/1491/files, works for me as well, but please include this or something better out-of-the-box, since everyone will start experience this sooner or later.
Yes,When the programe become more and more large, AOT compress will encounter heap out of memory.When i use the above method to solve.There was another mistake.
@pilgylis The change does not fix the AoT memory issue but it got built successfully since AoT configuration is ignored and it built as non-AoT
What do you mean, not built as AoT? I only took this part from the proposed fix, "webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js", that is increasing the memory and then node does not run of of memory anymore and the AoT build is successful.
@WillooWisp I did not use this proposal, it will be very slow when doing AOT compression, but did not throw a memory overflow
It sounds like there is no good solution yet. Why is this issue closed?
The proposed solution seems to work. The trick is to make sure AOT mode is on. I have installed cross-env
npm install --save-dev cross-env
In package json, I have created a new script:
"aotwebpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js",
I leave the existing "webpack" script alone.
I changed "build:aot:prod" to:
"build:aot:prod": "npm run clean:dist && npm run clean:aot && cross-env BUILD_AOT=1 npm run aotwebpack -- --config config/webpack.prod.js --progress --profile --bail",
And in webpack.common.js, just like the proposed solution:
const AOT = process.env.BUILD_AOT || helpers.hasNpmFlag('aot');
I am running angular 4.0.0-rc.5. I actually don't see much code reduction with aot -- I may have to change the way I import dependencies -- which I wish the tool can take care of this...
I have the same problem. Please reopen the issue.
@dereklin AOT does not mean code reduction...
@pilgylis AOT doesn't necessarily mean code reduction, but it should do tree shaking, which will generally mean code reduction. At the moment, tree shaking is broken in webpack 2.2. I'll wait for webpack 2.4 to see if tree shaking will work again without rewriting my import statements.
AOT converts the HTML templates into javascript so sometimes it even makes the code bigger. What you will benefit from it is that it saves you the time to do the compilation later.
Note: for support questions, please use one of these channels: Chat: AngularClass.slack or Twitter: @AngularClass
I'm submitting a ... [X ] bug report [ ] feature request [ ] question about the decisions made in the repository
Do you want to request a feature or report a bug? Reporting a bug
What is the current behavior? When I run npm run build:aot:prod
I get the following error: ==== JS stack trace ========================================= Security context: 00000133277CFB61
1: enter [C:\MyApp\node_modules\optimize-js\lib\index.js:~13] [pc=00000269B6CE8F25] (this=000002BBF4E471E1 <an Object with map 000000D02DAA96D1>,node=0000022D23C7E1B9 <a Node with map 000003DD7E69E889>,parent=0000023AC9B9F6D9 <a Node with map 000003DD7E694801>)
2: arguments adaptor frame: 4->2
3: visit(aka visit) [C:\MyApp\node_m...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
What is the expected behavior? To build successfully
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
Angular version: 2.4.6
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)