npm install - javascript heap out of memory

血红的双手。 提交于 2019-11-27 03:14:03

问题


When running npm install -g ionic I get the following error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Is there a way to globally increase the node.js memory limit?


回答1:


You can launch NPM using :

node --max_old_space_size=8000 $(which npm) install -g ionic

As described here, the default is 4000 (4Gb).




回答2:


I flagged this as a duplicate, but in case anyone happens across it, I posted the modern solution to this problem over at https://stackoverflow.com/a/48895989/4200039:

As of v8.0 shipped August 2017, the NODE_OPTIONS environment variable exposes this configuration (see NODE_OPTIONS has landed in 8.x!). Per the article, only options whitelisted in the source are permitted, which includes "--max_old_space_size".

So I put in my .bashrc: export NODE_OPTIONS=--max_old_space_size=4096




回答3:


Try, node --max-old-space-size=<size> where size is in megabytes.




回答4:


Run these commands

npm install -g increase-memory-limit

Run from the root location of your project:

increase-memory-limit

Look Here For more details https://www.npmjs.com/package/increase-memory-limit




回答5:


I had an incorrect prefix in my .npmrc file, just delete it.

prefix=D:\development\nodejs


来源:https://stackoverflow.com/questions/40112279/npm-install-javascript-heap-out-of-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!