我试图运行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 cache clean——force 运行NPM install

TLDR

对于那些使用NVM的人,请确保您使用的是正确的Node和NPM版本!

背景

我开始得到这个错误后,我开始使用NVM为不同的项目。当我为我的工作在一个项目上运行npm install时,我得到了这个错误,说明已经超过了最大调用堆栈大小。

这是由于我使用了Node 12及其附带的NPM版本,而我本应该使用Node 16。

解决方案

切换到Node和NPM的最新版本; NVM使用<版本>(例如,NVM使用16)

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

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

我遇到了同样的问题,但在我的情况下,我从一开始就使用yarn,但从一些包自readme中,我复制了npm install命令,得到了这个错误。后来意识到yarn add <package-name>解决了这个问题,包被安装了。

它可能在将来帮助别人。

我尝试了这个线程中的所有建议,但没有一个有效,我一直得到RangeError:当我运行'npm install'时,超过了最大调用堆栈大小。我决定直接运行npm start,它成功启动,没有错误…