Deploy failed today: Build was terminated: Build script returned non-zero exit code: 1

Hello, I am creating a site in React with Sanity.io for my friends, here is the link:
http://airis-quartet.netlify.app/

I have added a new page today and pushed everything to my github, then the build has failed.
To be honest, I don’t know what is going on, I have only added a new component which is a new page, that’s all. I haven’t added any NPM libraries from the last commit with succesfull build.

Could someone help me?

Here is the deploy log:

( I can’t add more than 6 links into the post )

The error is a peer dependency conflict relating to versions of react, which provides guidance on how you can attempt to resolve it:

11:06:39 AM: npm ERR! Fix the upstream dependency conflict, or retry
11:06:39 AM: npm ERR! this command with --force, or --legacy-peer-deps
11:06:39 AM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

It suggests you can run npm install --force or npm install --legacy-peer-deps.

To do this on Netlify you can use the NPM_FLAGS environment variable.

NPM_FLAGS: used to indicate the flags to pass to the npm install command.

Setting it to either --force or --legacy-peer-deps depending on your preference.

5 Likes
React Project causing npm ERR! code ERESOLVE while netlify deployment from github, where as build successfully on my localhost
Deploy failed NPM
Deploying problem
Build script returned non-zero exit code: 2 - I added logos and broke it
Error while resolving: react-lottie@1.2.3 Found: react@18.2.0
Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code
Gatsby 5 upgrade error
Netlify is failing to build the React Js Site
Build works locally but deploy fails when pushed to github
Unable to deploy my react app
Deploy failed to Publish website
Error on deployment
I am facing the error on deployment
Can't deploy next.js site
My react application is not showing up
I am facing build error while deploying the project
I am facing build error while deploying the project
Sanity Portfolio Starter build fails without clearing cache
Build script returned non-zero exit code: 1
Conflicting peer dependency it builds fine locally but i don't know what to do now ? especially that i'm trying to deploy a three js web app which works fine on desktop but the images doesn't render and crash on mobile for some reason
Error at deployment of a nextjs application
Conflicting peer dependency it builds fine locally but i don't know what to do now ? especially that i'm trying to deploy a three js web app which works fine on desktop but the images doesn't render and crash on mobile for some reason
Estou com problemas para fazer deploy por conflito de alguma coisa
Initializing error, the files run perfectly in the local system, but Netlify is not able to run them
Fail to Deploying a react project from GitHub
Gatsby-plugin-react-i18next is not compatible with your gatsby version 5.12.3
Sanity Portfolio Starter build fails without clearing cache
Build fails on Gatsby & Sanity site deploy with error for invalid lock file
Deploy fails on node-gyp-build command (migration from gatsby to netlify)
How to solve this error my website deployment?
Gatsby Build fail
Deploy versions problem vite and vuetify
How to modify the behavior of the initializing step? Like preventing `npm install`
Conflicting peer dependency: @types/react@17.0.50
Problems with deploy
Building Falied
The build process fails
Spline iframe in Vue.js portfolio not deploying

This fixed the issue I had today :slight_smile: But what is the reason it becomes an issue all of a sudden? The source code and settings were never changed for months

@Rico_Chen Do you have a package-lock.json with specific pegged versions of the various dependencies in your repo?

If not, then you aren’t necessarily building with precisely the same dependency versions each time you build.

This only became an issue with Node 16.15.1 (npm 8.11.0). I had a similar issue, but I definitely had a package-lock file built with —legacy-peer-deps

I am also curious what is causing the sudden need for npm flags.

Because Node.js decided to release an update which broke this.

1 Like

@hrishikesh Not surprising. Wouldn’t be the first sloppy npm release…

Do you know what exactly is causing the error?

Here’s a detailed post which explains the issue:

@hrishikesh I mean why did it suddenly break specifically in Netlify with 16.15.1? I have been using the —legacy-peer-deps flag to make my package-lock file since npm 8.0.0, and only now is Netlify giving me a build error.

Additionally, I can still build and serve this package locally. There has to be something more happening here.

I don’t see how that is related.

As pointed in the above link, the problem is because of:

If you already have a peerDependency installed, but not with a version named by the module, then NPM v7+ will throw an error

So something in your dependencies is using a version of one of the other dependencies which has a different version.

@hrishikesh This isn’t the answer.

Something is causing the need to set the legacy-peer-deps flag in Netlify’s environmental variables specifically with Node 16.15.1.

This isn’t a npm 7+ thing. This is specifically an issue with the way Netlify is building packages with npm v8.11.0, which requires an env var that was not required with v8.5.5.

We’ve done nothing special to change this behaviour. There’s no reason for Netlify to trigger a change that would specifically affect a minor x.x.1 update in Node.js and break so many builds.

I’ve always used the NODE_VERSION as node in my Site Settings. So I have been using version 16.5.1+ much before it went into the “latest LTS” stage a few days ago and I’m having this issue since then.

To be clear, we’re not doing anything special with building packages or installing Node Modules. We’re simply calling npm install:

Now why that breaks, especially due to a change of version with Node.js? I think that’s a question for the variable that’s changing here.

These packages build fine locally with the proper install flags, so whether it makes sense or not, this is an issue affecting Netlify. Might be worth looking into a bit further.

Does Netlify not use package-lock when installing?

I added this variable as shown in the img to netlify and the deploy fails the same as before.

As discussed in the helpdesk, you could choose to use --force or downgrade your Node Version.

–force not working either. Investigating how to use previous version of node in project.

@ZainoLabs You can use a previous version of node via any of the methods of specifying a node version.

The NODE_VERSION environment variable, or a .node-version / .nvmrc file.

I’ve encountered the same issue starting with 16.15.1.
Setting NPM_FLAGS to --legacy-peer-deps has resolved it for now.
The package-lock.json was built with --legacy-peer-deps.

1 Like

Thanks you it’s solved my problem

You made my dat <3 this fixed my issue also