我试图运行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,并尝试重新安装。不能理解是什么原因导致了这个,以及如何解决它。


当前回答

我不知道为什么,但我用sudo运行npm install,它工作了。

sudo npm install

其他回答

我也有同样的问题。我尝试过以前的解决方案,但对我来说,解决方案要简单得多。我只需要删除目录中的空格,然后再次运行npm I

感谢:https://github.com/nodejs/node-gyp/issues/809#issuecomment-155019383指出这一点。

在我的例子中,我有一个自定义的.npmrc文件,其中包括一个用于使用私有npm注册表进行身份验证的认证令牌。

令牌已经过期,这有助于返回代码E401:本地密码不正确或丢失,但ERR!CI构建超出了最大调用堆栈大小。

npm cache clean --force

这适用于我的节点8和npm 6+

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

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

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

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

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