我试图运行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 ci比npm install要方便得多。请查看这个SO答案,了解在生产环境中前者相对于后者的优势。 所以请跑吧

npm ci

所有依赖项都将被更新,问题就会消失。如果两者之间有严重的不同步,它就会出错。

其他回答

大多数情况下,如果您使用的是您工作的组织提供的系统,并且其vpn限制了此命令的使用,则会发生此问题。 在这种情况下,可以先尝试断开组织vpn连接,然后再执行该命令。

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

我尝试了一切方法来解决这个问题在我的windows 7机器上

重新安装和重建npm

最后,我浪费了一整天的时间,解决了这个小配置设置问题。

我是如何解决这个问题的

删除全局.npmrc中的项目特定配置 例如drive:/Windows/Users/.. npmrc

我100%解决了这个问题,我在gulp 3.5.6版本遇到了这个问题。

你应该清理package-lock.js,然后运行npm install和It working form

我也遇到了同样的错误,我试图将笑话安装到monorepo项目中的一个包中。

如果你使用Yarn + Learna来打包一个monorepo项目,你必须导航到这个包。Json在目标包中,然后运行NPM install或NPM install <包名>。