简体   繁体   English

Netlify 构建因 React 应用程序中的 npm 错误而失败

[英]Netlify build failed for npm error in react app

this is the failed build log from.netlify build log.这是来自 .netlify 构建日志的失败构建日志。 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: react-reveal@1.2.2
10:16:56 AM: Creating deploy upload records
10:16:56 AM: npm ERR! Found: react@17.0.2
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/react@2.2.4
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 react-reveal@1.2.2
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: react@16.14.0
10:16:56 AM: npm ERR! node_modules/react
10:16:56 AM: npm ERR!   peer react@"^15.3.0 || ^16.0.0" from react-reveal@1.2.2
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?我猜这可能是 NPM。我应该删除我安装的依赖项并再次使用 --force 标志重新安装它们吗? I am using npm version 8. How can I solve this problem?我正在使用 npm 版本 8。我该如何解决这个问题?

I was facing same issue while deploying to Netlify and all the checks on my PRs were failing.我在部署到 Netlify 时遇到了同样的问题,对我的 PR 的所有检查都失败了。 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经过一番搜索后,找到了 Netlify 论坛中提到的解决方案 - 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 .就我而言,我能够通过在构建命令npm run build --force之后添加--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.此外,必须在NODE_VERSION env 变量设置为16.15.0 ,因为显然问题发生在 Node 版本16.15.1中,而该版本正是用于构建的版本。

That's the same Node version mentioned in your post -这与您的帖子中提到的节点版本相同 -

10:16:51 AM: Now using node v16.15.1 (npm v8.11.0)上午 10:16:51:现在使用节点 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.如果我使用的解决方案不适合您,则上面提供的链接中也提到了其他一些解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将反应应用程序部署到 netlify 时出现 NPM 错误 - NPM error when deploying react app to netlify Netlify 无法构建 React 应用程序 - 命令失败,退出代码为 1 - Netlify fails build for React app - Command failed with exit code 1 Netlify 使用 create-react-app (CRA) 网站构建错误 - Netlify build Error using create-react-app (CRA) website 部署React应用到Netlify时缺少构建脚本错误 - Missing Build scripts error in Deploying react app to netlify Netlify 'build.command failed: base: /opt/build/repo/client' 用于部署 React 应用程序 - Netlify 'build.command failed: base: /opt/build/repo/client' for deploying React app 在NPM开发版本中反应应用程序部署错误 - React app deployment error in npm development build Reactjs (Create React App, CRA) npm run build failed and throw Error: ... envelope routines::unsupported - Reactjs (Create React App, CRA) npm run build failed and throw Error: ... envelope routines::unsupported 为什么我收到错误:运行 npm ci & run npm 构建失败时,将更改推送到部署在 Firebase 上的 React 应用程序? - Why do I get error: run npm ci & run npm build failed when pushing changes to React app that is deployed on Firebase? 由于 css 中的 calc(width),React 应用程序中的“npm run build”失败? - “npm run build” failed in React app due to calc(width) in css? 如何解决 npm run build 的 React 应用程序错误“无法编译。无法缩小包。”? - How do I resolve the React app error for npm run build "Failed to compile. Failed to minify the bundle."?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM