【问题标题】:How to fix "npm ERR! Maximum call stack size exceeded" in Google Cloud Build?如何修复 Google Cloud Build 中的“npm ERR!超出最大调用堆栈大小”?
【发布时间】:2020-10-23 05:40:43
【问题描述】:

我最新的 Google Cloud 构建失败并出现以下错误:

Step 3/16 : RUN npm i
 ---> Running in 9b3b8df05c12
npm notice 
npm notice New patch version of npm available! 7.0.2 -> 7.0.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.3>
npm notice Run `npm install -g npm@7.0.3` to update!
npm notice 
npm ERR! Maximum call stack size exceeded

最后一次成功构建是在 10 月 17 日。从那时起,我只提交了一个更改了一些打字稿的提交。 dockerfile 或 NPM 依赖项中没有任何变化。

Dockerfile 的相关部分如下所示:

FROM node AS minifier
COPY MyProject/Client .
RUN npm i
RUN npm install -g grunt-cli rollup
RUN grunt release

看起来问题出在RUN npm i 命令上。这是一个错误吗?有什么我可以解决的吗?我确实重试了构建,但遇到了同样的错误。

【问题讨论】:

    标签: docker npm npm-install google-cloud-build


    【解决方案1】:

    这是由于最新版本的 npm(即 v7.0.3)引起的问题。有多种选择:

    • 您可以将基础镜像更改为node:15.0.0node:15.0.0-slim
    • 使用 yarn 代替 npm 也可以解决此问题
    • 在您的 Dockerfile 中,在 npm i 之前运行 npm cache clean --force

    我建议更改基本映像。

    【讨论】:

    • 谢谢!指定较旧的节点映像解决了该问题。
    猜你喜欢
    • 2021-02-12
    • 2020-08-03
    • 2019-03-01
    • 1970-01-01
    • 2019-09-09
    • 1970-01-01
    • 2019-07-19
    • 1970-01-01
    • 2019-06-29
    相关资源
    最近更新 更多