admin管理员组文章数量:1398840
In Angular 7 application, When I execute ng serve mand, it throws "JavaScript heap out of memory" error.
From different SO answers, I can understand that the issue is due to insufficient memory allocation to Node. As mentioned in their answers, by executing the below mand I am able to pile/build the angular application.
node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng serve
But I need this memory allocation code written inside package.json or some configuration file so that I need not to execute the whole mand each and every time. Also expecting, code logic should apply to all environments and should not create any issue during build in higher environments.
Can someone please help me to fix this. Below is my package.json code.
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
In Angular 7 application, When I execute ng serve mand, it throws "JavaScript heap out of memory" error.
From different SO answers, I can understand that the issue is due to insufficient memory allocation to Node. As mentioned in their answers, by executing the below mand I am able to pile/build the angular application.
node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng serve
But I need this memory allocation code written inside package.json or some configuration file so that I need not to execute the whole mand each and every time. Also expecting, code logic should apply to all environments and should not create any issue during build in higher environments.
Can someone please help me to fix this. Below is my package.json code.
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Share
Improve this question
asked Apr 24, 2020 at 1:40
Tech LearnerTech Learner
1,3177 gold badges30 silver badges71 bronze badges
1
- You can add NODE_OPTIONS ( URL - > support.snyk.io/hc/en-us/articles/… ) environment variable but it will crash your VS application if it is lower than 2017 version. – Tech Learner Commented Apr 24, 2020 at 1:44
1 Answer
Reset to default 4First run This:
npm install -g increase-memory-limit
Then add this line on your package.json file:
"myCustomMemoryComm ": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng"
Like this:
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"myCustomMemoryComm": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng"
},
Then your further mand will be every time for running the project (serve):
npm run myCustomMemoryComm -serve
Or Direct Run this on console:
node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng
And For Production build:
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --baseHref=/your-project-name/ --prod=true
本文标签: nodejsAngular 7JavaScript heap out of memory errorStack Overflow
版权声明:本文标题:node.js - Angular 7 - JavaScript heap out of memory error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744123009a2591826.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论