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

npm cache clean --force

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

npm install

其他回答

rm -rf node_modules

然后重新安装对我来说很有效。

注意:可能不需要撕下你的锁文件

如果这些答案都不适合你,这可能是因为你正在使用的终端不是正确的/你的node_modules被你计算机的另一部分使用。

在我的情况下,我一直在这个错误(最大调用堆栈大小超过)和访问错误事件之间杂耍,当我做了一个sudo npm I。

解决办法是关闭我的IDE(也就是WebStorm),在一个基本终端上运行npm i,就是这样。

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

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

一般来说,一旦一个模块安装好了,使用npm ci比npm install要方便得多。请查看这个SO答案,了解在生产环境中前者相对于后者的优势。 所以请跑吧

npm ci

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

我也遇到过同样的问题,我是这样解决的。

First of all you need to make sure that your node and npm versions are up to date. if not please upgrade your node and npm packages to latest versions. nvm install 12.18.3 // update node version through node version manager npm install npm // update your npm version to latest Delete your node_modules folder and package-lock.json file. Force clean the entire NPM cache by using following comand. npm cache clean --force Re-Install all the dependencies. npm install If above step didn't resolve your problem, try to re-install your dependencies after executing following command. npm rebuild