我试图运行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  

这就解决了问题。

其他回答

我有这个问题,这是由于升级我的git可执行文件。我回滚到Git-2.21.0.rc1.windows。1-64位,并将其添加到我的环境路径,它修复了我的问题。

npm uninstall

npm cache clean --force

我试过这两种方法,但都不奏效。之后,我删除了node_modules目录并再次运行npm install,它仍然不起作用。最后,我删除了package-lock。Json,并创建了一个新的包锁。Json文件使用

npm install

我有这个问题,原来,我有一个符号链接node_modules内指向它的父,即。

[user@localhost]$ ls -la /path/to/project/node_modules
total 3272
...
lrwxrwxrwx   1 user user  50 Nov 26 18:38 node_modules -> ../node_modules
...

我的意思是,我搞砸了bash脚本,它创建了一个循环符号链接。删除符号链接解决了这个问题。

以下步骤帮助我解决了这个问题:

停止所有的反应条(例如开始构建) 运行NPM cache clean——force 运行NPM install

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

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

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