We have run into the same problem. After updating the environment variables with v16.15.0 our builds all seem to be working!
I have the same issue, while using Node v16.15.1 (npm v8.11.0).
@dana-blackbean what do you mean with “updating the environment variables with v16.15.0”?
@nhoizey, you can set an environmental variable in Netlify’s dashboard (Site Settings → Build & Deploy → Environment) to dictate which version of node Netlify uses.
Set a variable with the key NODE_VERSION
and value 16.15.0
.
This was incredibly helplful to me thank you!
Ok, instead of an environment variable, I used my already existing .nvmrc
file to set Node to 16.5.0, and it now works!
Another fix here: Deploy failed today: Build was terminated: Build script returned non-zero exit code: 1 - #4 by nathanmartin
You can set npm flags in Netlify to build using —force
or —legacy-peer-deps
. Even if your package-lock file was built using one of those flags, they seem to be broken or ignored by Netlify with 16.15.1.
EDIT: Node introduced this error by changing the way the npm ci
command builds sites with 16.15.1. Read more on their github issues page.
Thanks, I had the same issue and resolved it with the NPM_FLAGS environment variable.
This was a massive help, I went right round the houses on a Sanity/Gatsby project, I needed to change NODE_VERSION on both studio and web I think.
Thanks!
Note that, Node 16 has been declared as reaching End Of Life by 2023:
So the long-term solution would be to use NPM_FLAGS
instead of downgrading Node Version.
Why is NPM_FLAGS needed only starting with npm v8.11.0? We have needed to build with —legacy-peer-deps since npm v7, but suddenly Netlify is requiring an environmental variable to build properly.
I asked this before and didn’t get an answer, but shouldn’t the package-lock file take care of this issue? If I set the proper flags when creating package-lock, I would not expect Netlify to build differently from that.
If we need to use npm flags going forward, I would request supporting the .npmrc file, which already allows us to set flags for a project. At least it would be consistent with your .nvmrc support.
I dropped answering your question, because you seemed to be interested to prove this is a Netlify problem when it simply is not. But to answer your question, a quick Google search shows this:
About this, we could try to pass that on as a feature request (or maybe it already works - I’ve never tried that).
Wait… So you knew the answer to my question before, but didn’t answer because you thought I was slighting Netlify? That’s honestly a bit unprofessional.
Anyways, thank you for the answer. You may want to figure out a way to surface the info about NPM_FLAGS more easily, since it is now required for many (most?) projects.
.npmrc was not working when I initially had this issue, I haven’t tested it since downgrading node.
The issue is from 4 days ago, we had that discussion a week ago - so to answer that part, no I did not know. The only thing I was sure about was this is a Node.js/npm issue and not a Netlify issue. I tried looking back then, but didn’t find anything useful.
This time, i decided to dig again, with different search queries, and landed on that.
I agree,
Surfacing that information would make more sense. I’ll pass this to the docs team to see what the best way for this would be.
oh thank God for this! lol. this fixed my problem, and I learned something new! I was panicking!
Hey folks!
Just following up here. Our Documentation team has updated our Docs to include setting the NPM_FLAGS
environment variable to pass either --force
or --legacy-peer-deps
to the npm install
command that Netlify runs at build time.
Thank you for all of the thoughtful collaboration on this thread, and helping us improve our documentation.
Happy building!
Thank you very much!! It was very helpful!
Hi @rafamessias
Welcome to the community!
Thanks for letting us know this thread helped you. We always appreciate the feedback!
That link directs to a Page Not Found.
Hey there, @kmacgregor
Thanks for raising that point! I have gone back and fixed the link. It should now work
Finally!!! Thank you so much!!