npm install - javascript 堆内存不足
npm install - javascript heap out of memory
当 运行 npm install -g ionic
我得到以下错误:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
有没有办法全局增加 node.js 内存限制?
尝试,node --max-old-space-size=<size>
其中大小以兆字节为单位。
您可以使用以下命令启动 NPM:
node --max-old-space-size=8000 $(which npm) install -g ionic
如所述here,默认值为 4000 (4Gb)。
我将其标记为重复,但以防万一有人碰到它,我在 :
上发布了针对此问题的现代解决方案
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
运行 这些命令
npm install -g increase-memory-limit
运行 从项目的根位置:
增加内存限制
查看此处了解更多详情https://www.npmjs.com/package/increase-memory-limit
我的 .npmrc 文件中的前缀不正确。通过移动到新的公司设备,这条路径不再与旧的 nodejs 文件夹匹配。在 npm install 上,命令冻结了很长时间,并在没有合适答案的情况下抛出 java 堆外异常。
我已经删除了它并且有效。
prefix=D:\development\nodejs
为我解决了,在 运行 命令之后:
npm update
它将更新所有依赖项(小心损坏的更改)。也许 webpack-cli
依赖项是导致此问题的原因。
我遇到了类似的问题,这种方法对我不起作用,因为我使用的是 docker,所以我不得不增加 docker 本身的内存大小来解决问题:
Docker Screenshot
对于 Angular 11 / 10 在 pacakge.json 文件中进行以下更改
来源Link
"scripts": {
"ng": "ng",
"start": "node --max_old_space_size=2192 ./node_modules/@angular/cli/bin/ng serve",
"build": "node --max_old_space_size=2192 ./node_modules/@angular/cli/bin/ng build",
.....
},
试试这个生活妙招
NODE_OPTIONS="--max-old-space-size=2048" npm install -g ionic
当 运行 npm install -g ionic
我得到以下错误:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
有没有办法全局增加 node.js 内存限制?
尝试,node --max-old-space-size=<size>
其中大小以兆字节为单位。
您可以使用以下命令启动 NPM:
node --max-old-space-size=8000 $(which npm) install -g ionic
如所述here,默认值为 4000 (4Gb)。
我将其标记为重复,但以防万一有人碰到它,我在 :
上发布了针对此问题的现代解决方案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
运行 这些命令
npm install -g increase-memory-limit
运行 从项目的根位置:
增加内存限制
查看此处了解更多详情https://www.npmjs.com/package/increase-memory-limit
我的 .npmrc 文件中的前缀不正确。通过移动到新的公司设备,这条路径不再与旧的 nodejs 文件夹匹配。在 npm install 上,命令冻结了很长时间,并在没有合适答案的情况下抛出 java 堆外异常。
我已经删除了它并且有效。
prefix=D:\development\nodejs
为我解决了,在 运行 命令之后:
npm update
它将更新所有依赖项(小心损坏的更改)。也许 webpack-cli
依赖项是导致此问题的原因。
我遇到了类似的问题,这种方法对我不起作用,因为我使用的是 docker,所以我不得不增加 docker 本身的内存大小来解决问题:
Docker Screenshot
对于 Angular 11 / 10 在 pacakge.json 文件中进行以下更改
来源Link
"scripts": {
"ng": "ng",
"start": "node --max_old_space_size=2192 ./node_modules/@angular/cli/bin/ng serve",
"build": "node --max_old_space_size=2192 ./node_modules/@angular/cli/bin/ng build",
.....
},
试试这个生活妙招
NODE_OPTIONS="--max-old-space-size=2048" npm install -g ionic