Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "npm ERR! Maximum call stack size exceeded" in Google Cloud Build?

My latest Google Cloud Builds are failing with the following error:

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 [email protected]` to update!
npm notice 
npm ERR! Maximum call stack size exceeded

The last successful build was on October 17th. Since then, I have only made one commit which changed some typescript. Nothing in the dockerfile or NPM dependencies has changed.

The relevant section of the Dockerfile looks like this:

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

It looks like the issue is specifically with the RUN npm i command. Is this a bug? Is there anything I can do to fix it? I did retry the build, but encountered the same error.

like image 553
Morgan Roff Avatar asked Dec 06 '25 18:12

Morgan Roff


1 Answers

This is an issue caused due to the latest release of npm i.e. v7.0.3. There are multiple alternatives to this:

  • You can change the base image to node:15.0.0 or node:15.0.0-slim
  • Alternatively using yarn instead of npm can also fix this issue
  • Run npm cache clean --force before npm i in your Dockerfile

I'd recommend changing the base image.

like image 96
ahmedwaleedmalik Avatar answered Dec 08 '25 12:12

ahmedwaleedmalik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!