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

Hello, I am creating a site in React with for my friends, here is the link:

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.


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