node.js npm install - javascript 堆内存不足
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40112279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install - javascript heap out of memory
提问by gunwin
When running npm install -g ionicI get the following error:
运行时npm install -g ionic出现以下错误:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
致命错误:CALL_AND_RETRY_LAST 分配失败 - JavaScript 堆内存不足
Is there a way to globally increase the node.js memory limit?
有没有办法全局增加 node.js 内存限制?
采纳答案by xShirase
回答by Ben Creasy
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:
我将此标记为重复,但万一有人遇到它,我在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
从 2017 年 8 月发布的 v8.0 开始,NODE_OPTIONS 环境变量公开了此配置(请参阅 NODE_OPTIONS 已登陆 8.x!)。根据文章,仅允许在源中列入白名单的选项,其中包括“--max_old_space_size”。
所以我输入了我的 .bashrc:export NODE_OPTIONS=--max_old_space_size=4096
回答by Fouzia Khan
Run these commands
运行这些命令
npm install -g increase-memory-limit
npm install -g 增加内存限制
Run from the root location of your project:
从项目的根位置运行:
increase-memory-limit
增加内存限制
Look Here For more details https://www.npmjs.com/package/increase-memory-limit
看这里了解更多详情https://www.npmjs.com/package/increase-memory-limit
回答by paolord
Try, node --max-old-space-size=<size>where size is in megabytes.
尝试,node --max-old-space-size=<size>其中大小以兆字节为单位。
回答by Antonio Carlos L Oliveira
Solved for me, after running the command:
运行命令后为我解决:
npm update
It will update all dependencies (be careful with broken changes). Maybe the webpack-clidependency is the cause of this trouble.
它将更新所有依赖项(小心损坏的更改)。也许webpack-cli依赖是造成这个麻烦的原因。
回答by Robin Bruneel
I had an incorrect prefix in my .npmrc file. By moving to new company devices this path didn't match anymore with the old nodejs folder. On npm install the command freezes for a long time and throws an java out of heap exception without a suitable answer.
我的 .npmrc 文件中有一个不正确的前缀。通过移动到新的公司设备,此路径不再与旧的 nodejs 文件夹匹配。在 npm install 上,命令冻结了很长时间,并在没有合适答案的情况下抛出 java 堆外异常。
I've deleted it and it worked.
我已经删除了它并且它起作用了。
prefix=D:\development\nodejs

