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

Posted

技术标签:

【中文标题】放大 cli : npm ERR!超出最大调用堆栈大小【英文标题】:Amplify cli : npm ERR! Maximum call stack size exceeded 【发布时间】:2020-08-03 08:18:56 【问题描述】:

执行时

npm install -g @aws-amplify/cli

结果

npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nashif Alam\AppData\Roaming\npm-cache\_logs\2020-04-20T17_44_57_963Z-debug.log

这是日志输出

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Nashif Alam\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   '@aws-amplify/cli'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.16.2
4 verbose npm-session 48145273415ef01a
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/@aws-amplify%2fcli 6012ms (from cache)
8 silly pacote tag manifest for @aws-amplify/cli@latest fetched in 6185ms
9 timing stage:loadCurrentTree Completed in 6274ms

//删除日志的其余部分,因为它在这种情况下似乎没用

916 silly resolveWithNewModule param-case@3.0.3 checking installable status
917 silly pacote version manifest for upper-case@2.0.1 fetched in 8ms
918 silly resolveWithNewModule upper-case@2.0.1 checking installable status
919 http fetch GET 200 https://registry.npmjs.org/@ardatan%2fgraphql-tools 1713ms
920 http fetch GET 200 https://registry.npmjs.org/@ardatan/graphql-tools/-/graphql-tools-4.1.0.tgz 5735ms
921 silly pacote version manifest for @ardatan/graphql-tools@4.1.0 fetched in 7453ms
922 silly resolveWithNewModule @ardatan/graphql-tools@4.1.0 checking installable status
923 silly pacote range manifest for dot-case@^3.0.3 fetched in 2ms
924 silly resolveWithNewModule dot-case@3.0.3 checking installable status
925 silly pacote version manifest for @graphql-toolkit/common@0.9.7 fetched in 5ms
926 silly resolveWithNewModule @graphql-toolkit/common@0.9.7 checking installable status
927 silly fetchPackageMetaData error for relay-compiler@8.0.0 Response timeout while trying to fetch https://registry.npmjs.org/relay-compiler (over 30000ms)
928 verbose stack RangeError: Maximum call stack size exceeded
928 verbose stack     at RegExp.test (<anonymous>)
928 verbose stack     at isDepOptional (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:428:45)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:437:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
928 verbose stack     at failedDependency (C:\Users\Nashif Alam\AppData\Roaming\npm\node_modules\npm\lib\install\deps.js:453:9)
929 verbose cwd C:\Users\Nashif Alam
930 verbose Windows_NT 10.0.18363
931 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Nashif Alam\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@aws-amplify/cli"
932 verbose node v12.16.2
933 verbose npm  v6.14.4
934 error Maximum call stack size exceeded
935 verbose exit [ 1, true ]

npm 版本是 6.14.4 节点版本为 v12.16.2

我尝试安装节点 10,仍然出现同样的错误

而且,每次日志大多卡在Response timeout while trying to fetch https://registry.npmjs.org/**Different link everytime**

【问题讨论】:

这能回答你的问题吗? Maximum call stack size exceeded on npm install 我尝试了该线程中所有可能的解决方案,当它们都不起作用时,我在这里发布了问题,可能问题不在于 Amplify,而在于 nodejs 【参考方案1】:

使用以下命令对我有用

npm cache clean --force

【讨论】:

【参考方案2】:

我找到了问题的答案,这可能与 Nodejs 版本 12.16 和许多其他早期版本(如 5.0 和 10)有关;但是使用 13.13 版本解决了这个问题,并且命令运行没有问题。

【讨论】:

【参考方案3】:

对我来说,日志看起来像这样:

// ... skipping some deprecation warnings

> core-js@3.6.5 postinstall /root/.nvm/versions/node/v14.10.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-graphql-types-generator/node_modules/core-js
> node -e "tryrequire('./postinstall')catch(e)"

sh: 1: node: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/@aws-amplify/cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: 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!     /root/.npm/_logs/2020-09-10T14_10_28_397Z-debug.log

请注意 sh: 1: node: Permission denied 引导我访问 https://forum.vuejs.org/t/cannot-install-vue-cli-permission-error-in-require-postinstall/82017/7

我必须在安装命令中添加--unsafe-perm 并以 root 身份运行它(我已经是 WSL 中的 root):

npm install -g --unsafe-perm @aws-amplify/cli

【讨论】:

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

npm 错误! npm install 时超出最大调用堆栈大小(角度)

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

猫鼬超过了Nodejs的最大调用堆栈大小

“RangeError:超出最大调用堆栈大小”为啥?

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

超出最大调用堆栈大小 - 没有明显的递归