我试图运行npm install,这是控制台的输出:

npm ERR! Linux 4.8.0-27-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8

npm ERR! Maximum call stack size exceeded
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

这是npm-debug.log的内容:

113791 verbose stack RangeError: Maximum call stack size exceeded
113791 verbose stack     at Object.color (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/console-control-strings/index.js:115:32)
113791 verbose stack     at EventEmitter.log._format (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:252:51)
113791 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:138:24)
113791 verbose stack     at emitThree (events.js:116:13)
113791 verbose stack     at emit (events.js:194:7)
113791 verbose stack     at .<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js:23:18)
113791 verbose stack     at emitThree (events.js:116:13)
113791 verbose stack     at emit (events.js:194:7)
113791 verbose stack     at .<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js:23:18)
113791 verbose stack     at emitThree (events.js:116:13)
113791 verbose stack     at emit (events.js:194:7)
113792 verbose cwd /home/giorgi/AdMove/dev/web-advertiser-admove
113793 error Linux 4.8.0-27-generic
113794 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
113795 error node v6.9.1
113796 error npm  v3.10.8
113797 error Maximum call stack size exceeded
113798 error If you need help, you may report this error at:
113798 error     <https://github.com/npm/npm/issues>
113799 verbose exit [ 1, true ]

多次删除node_modules,并尝试重新安装。不能理解是什么原因导致了这个,以及如何解决它。


当前回答

我也遇到过类似的错误。我追踪到npm无法从npm链接文件夹的.bin文件夹中删除文件的事实。所以我进入并rm -rf npm链接文件夹中所有的。bin文件夹。

find "linked-folder" -type d -name ".bin" -print  
For all folders listed | rm -rf  

这就解决了问题。

其他回答

NPM缓存清理返回下面的消息 从npm@5开始,npm缓存会从损坏问题中自我修复,并且从缓存中提取的数据保证是有效的。如果你想确保所有内容都是一致的,请使用'npm cache verify'。另一方面,如果你正在调试安装程序的问题,你可以使用npm install——cache /tmp/empty-cache来使用一个临时缓存,而不是破坏实际的缓存。

如果你运行npm缓存校验,就像上面指定的那样,那么它实际上会运行缓存校验和垃圾收集来修复这个问题。

缓存验证和压缩(~\AppData\Roaming\npm- cache_cache): 内容验证:6183(447214684字节)内容垃圾收集:16 (653745 bytes)索引项:9633

如果试图安装不存在的包或试图安装不存在的版本,也会发生此问题。

我删除了

node_modules

然后重新安装

npm安装

这对我很有效

我在Mac上最终成功的一件事是从8.12节点升级到10节点。x使用NVM。

我用NVM卸载了所有其他版本的Node,然后安装了10。x,然后运行nvm alias default node,它告诉nvm总是默认为shell上最新可用的节点版本。

在那之后,我的实时重新加载问题消失了!

对于那些在使用Jenkins(或任何CI)构建Docker映像时遇到此问题的人,请确保package-lock。Json也被复制到容器中。

COPY ./src/package*.json /home/node/
RUN npm install

对我们来说,安装实际上很好,错误只发生在运行npm prune production生产映像时。