npm 错误!超出最大调用堆栈大小

Posted

技术标签:

【中文标题】npm 错误!超出最大调用堆栈大小【英文标题】:npm err! maximum call stack size exceeded 【发布时间】:2019-07-19 01:40:18 【问题描述】:

我正在使用 NPM,项目进展顺利。过了一会儿,我删除了node_modules 文件夹并开始出现错误。 系统:Macbook Pro

2814 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
2815 verbose node v11.9.0
2816 verbose npm  v6.5.0
2817 error Maximum call stack size exceeded
2818 verbose exit [ 1, true ]

已尝试修复: 删除了 package-lock.json 并尝试使用 npm i -> 仍然给出相同的错误。 尝试使用npm rebuild -> 不走运 尝试使用npm cache-clean --force -> 不走运

在进行调查时 - 如果我从 devDependencies 中删除 "@frctl/fractal": "^1.1.7" - npm install 工作正常。因为,直到现在它工作得很好。所以,不知道真正的原因。 以下是devDependencies 列表:

"devDependencies": 
"@frctl/fractal": "^1.1.7",
"@frctl/mandelbrot": "^1.2.0",
"node-sass": "^4.11.0",
"angular": "^1.3.15",
"typescript": "^3.2.2",
"autoprefixer": "^6.7.7",
"browser-sync": "^2.18.8",
"del": "^2.2.2",
"glob": "^7.1.1",
"gulp": "^4.0.0",
"gulp-babel": "^6.1.2",
"gulp-changed": "^2.0.0",
"gulp-concat": "^2.6.1",
"gulp-environments": "^0.1.2",
"gulp-flatten": "^0.3.1",
"gulp-htmlmin": "^3.0.0",
"gulp-iconfont": "^10.0.2",
"gulp-iconfont-css": "^2.3.0",
"gulp-if": "^2.0.2",
"gulp-imagemin": "^3.2.0",
"gulp-notify": "^3.0.0",
"gulp-plumber": "^1.1.0",
"gulp-postcss": "^6.4.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.1.0",
"gulp-sass-glob": "^1.0.8",
"gulp-sourcemaps": "^2.4.1",
"gulp-surge": "^0.1.0",
"gulp-svg-sprite": "^1.3.6",
"gulp-svgmin": "^1.2.3",
"gulp-uglify": "^2.1.2",
"merge-stream": "^1.0.1",
"require-dir": "^0.3.1",
"@types/angular": "^1.6.53",
"@types/angular-mocks": "^1.7.0",
"@types/jasmine": "^3.3.7",
"@types/karma": "^1.7.1",
"@types/jquery": "^3.3.29",
"angular-mocks": "1.3.15",
"jasmine-core": "^2.8.0",
"jquery-ui": "^1.12.1",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "1.0.1",
"karma-coverage": "^1.1.2",
"karma-jasmine": "^1.1.0",
"karma-jquery": "^0.2.3",
"karma-junit-reporter": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-spec-reporter": "0.0.32",
"karma-typescript": "^3.0.13",
"ts-mockito": "^2.3.1",
"ts-node": "^8.0.1",
"@types/angular-translate": "^2.16.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-concat": "^0.5.1",
"@types/lodash": "^4.14.121"

解决此问题的任何建议。

提前致谢!

【问题讨论】:

这个建议 npm rebuild -g 为我工作。 【参考方案1】:

不知道有没有人遇到过这种问题。我通过生成 package-lock.json 解决了这个问题,它修复了构建问题。感谢支持!

【讨论】:

我无法理解生成package-lock.json。基本上,据我所知, package-lock.json 是自动生成的。有没有办法手动配置package-lock.json 只需删除 package-lock.json 并运行 npm install。然后它被生成。【参考方案2】:

我也有同样的问题

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted "os":"darwin","arch":"any" (current: "os":"linux","arch":"x64")

npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/veluvijay/.npm/_logs/2019-12-09T05_54_58_567Z-debug.log
Package install failed, see above.
See "/tmp/ng-K4aXCl/angular-errors.log" for further details.

将nodejs从version 10更新到version 12.03.1后,在我的机器上运行正常。

【讨论】:

我有同样的问题,所以我尝试将节点版本升级到最新的稳定版本。 14.x.x。但我仍然有一个问题。看起来主要原因与节点版本无关。 @AdelinIonut 您能找到解决此错误的任何解决方案吗? 不是真的,我还没有解决这个问题。

以上是关于npm 错误!超出最大调用堆栈大小的主要内容,如果未能解决你的问题,请参考以下文章

Angular 11最大调用堆栈大小超出错误

如何捕获“超出最大调用堆栈大小”错误?

放大 cli : npm ERR!超出最大调用堆栈大小

Angular 8 - ng lint:超出最大调用堆栈大小错误

Angular 5 表单组件导致错误:“RangeError:超出最大调用堆栈大小”

Angular 2 + CLI:超出最大调用堆栈大小错误