Home > Back-end >  Netlify build failed for npm error in react app
Netlify build failed for npm error in react app

Time:06-15

this is the failed build log from netlify build log. I build this yesterday. Now I am having problem with building the site

10:16:47 AM: Starting build script
10:16:47 AM: Installing dependencies
10:16:47 AM: Python version set to 2.7
10:16:47 AM: Downloading and installing node v16.15.1...
10:16:47 AM: Downloading https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.xz...
10:16:48 AM: Computing checksum with sha256sum
10:16:48 AM: Checksums matched!
10:16:51 AM: Now using node v16.15.1 (npm v8.11.0)
10:16:51 AM: Started restoring cached build plugins
10:16:51 AM: Finished restoring cached build plugins
10:16:51 AM: Attempting ruby version 2.7.2, read from environment
10:16:52 AM: Using ruby version 2.7.2
10:16:52 AM: Using PHP version 8.0
10:16:53 AM: No npm workspaces detected
10:16:53 AM: Started restoring cached node modules
10:16:53 AM: Finished restoring cached node modules
10:16:53 AM: Installing NPM modules using NPM version 8.11.0
10:16:54 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:16:54 AM: npm WARN config location in the cache, and they are managed by
10:16:54 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:16:54 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:16:54 AM: npm WARN config location in the cache, and they are managed by
10:16:54 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:16:56 AM: npm ERR! code ERESOLVE
10:16:56 AM: npm ERR! ERESOLVE could not resolve
10:16:56 AM: npm ERR!
10:16:56 AM: npm ERR! While resolving: [email protected]
10:16:56 AM: Creating deploy upload records
10:16:56 AM: npm ERR! Found: [email protected]
10:16:56 AM: npm ERR! node_modules/react
10:16:56 AM: npm ERR!   react@"^17.0.2" from the root project
10:16:56 AM: npm ERR!   peer react@">= 16.8.0" from @formspree/[email protected]
10:16:56 AM: npm ERR!   node_modules/@formspree/react
10:16:57 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
10:16:56 AM: npm ERR!     @formspree/react@"^2.2.4" from the root project
10:16:56 AM: npm ERR!   8 more (@testing-library/react, react-dom, react-icons, ...)
10:16:56 AM: npm ERR!
10:16:56 AM: npm ERR! Could not resolve dependency:
10:16:56 AM: npm ERR! peer react@"^15.3.0 || ^16.0.0" from [email protected]
10:16:56 AM: npm ERR! node_modules/react-reveal
10:16:56 AM: npm ERR!   react-reveal@"^1.2.2" from the root project
10:16:56 AM: npm ERR!
10:16:56 AM: npm ERR! Conflicting peer dependency: [email protected]
10:16:56 AM: npm ERR! node_modules/react
10:16:56 AM: npm ERR!   peer react@"^15.3.0 || ^16.0.0" from [email protected]
10:16:56 AM: npm ERR!   node_modules/react-reveal
10:16:56 AM: npm ERR!     react-reveal@"^1.2.2" from the root project
10:16:56 AM: npm ERR!
10:16:56 AM: npm ERR! Fix the upstream dependency conflict, or retry
10:16:56 AM: npm ERR! this command with --force, or --legacy-peer-deps
10:16:56 AM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
10:16:56 AM: npm ERR!
10:16:56 AM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
10:16:56 AM: npm ERR! A complete log of this run can be found in:
10:16:56 AM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-14T04_16_54_367Z-debug-0.log
10:16:56 AM: Error during NPM install
10:16:56 AM: Build was terminated: Build script returned non-zero exit code: 1
10:16:57 AM: Failing build: Failed to build site
10:16:57 AM: Finished processing build request in 13.567112014s

I am guessing this is probably for NPM. Should I delete my installed dependency and again reinstall them using --force flag? I am using npm version 8. How can I solve this problem?

CodePudding user response:

I was facing same issue while deploying to Netlify and all the checks on my PRs were failing. After a little searching around, found the solution mentioned in Netlify forums here - Fix for Build was terminated: Build script returned non-zero exit code: 1

In my case, I was able to get the issue resolved by adding the --force flag after the build command npm run build --force. Also, had to set the NODE_VERSION env variable to 16.15.0 in Netlify as apparently the issue has occurred in Node version 16.15.1 and that was the version which was being used for build.

That's the same Node version mentioned in your post -

10:16:51 AM: Now using node v16.15.1 (npm v8.11.0)

There are few other solutions mentioned as well on the link provided above if the one's I used don't work for you.

  • Related