React app deployment error安装NPM时出现的错误



错误:

12:28:55 PM: Installing NPM modules using NPM version 8.11.0
12:28:56 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:28:56 PM: npm WARN config location in the cache, and they are managed by
12:28:56 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:28:56 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:28:56 PM: npm WARN config location in the cache, and they are managed by
12:28:56 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:28:57 PM: npm ERR! code ERESOLVE
12:28:57 PM: npm ERR! ERESOLVE could not resolve
12:28:57 PM: npm ERR!
12:28:57 PM: npm ERR! While resolving: react-alert@7.0.3
12:28:58 PM: Creating deploy upload records
12:28:57 PM: npm ERR! Found: react@18.2.0
12:28:57 PM: npm ERR! node_modules/react
12:28:57 PM: npm ERR!   react@"^18.2.0" from the root project
12:28:57 PM: npm ERR!   peer react@"^18.0.0" from @testing-library/react@13.0.1
12:28:57 PM: npm ERR!   node_modules/@testing-library/react
12:28:58 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
12:28:57 PM: npm ERR!     @testing-library/react@"^13.0.1" from the root project
12:28:57 PM: npm ERR!   5 more (react-dom, react-router, react-router-dom, ...)
12:28:57 PM: npm ERR!
12:28:57 PM: npm ERR! Could not resolve dependency:
12:28:57 PM: npm ERR! peer react@"^16.8.1 || ^17" from react-alert@7.0.3
12:28:57 PM: npm ERR! node_modules/react-alert
12:28:57 PM: npm ERR!   react-alert@"^7.0.3" from the root project
12:28:57 PM: npm ERR!
12:28:57 PM: npm ERR! Conflicting peer dependency: react@17.0.2
12:28:57 PM: npm ERR! node_modules/react
12:28:57 PM: npm ERR!   peer react@"^16.8.1 || ^17" from react-alert@7.0.3
12:28:57 PM: npm ERR!   node_modules/react-alert
12:28:57 PM: npm ERR!     react-alert@"^7.0.3" from the root project
12:28:57 PM: npm ERR!
12:28:57 PM: npm ERR! Fix the upstream dependency conflict, or retry
12:28:57 PM: npm ERR! this command with --force, or --legacy-peer-deps
12:28:57 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
12:28:57 PM: npm ERR!
12:28:57 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
12:28:57 PM: npm ERR! A complete log of this run can be found in:
12:28:57 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-25T06_58_56_560Z-debug-0.log
12:28:57 PM: Error during NPM install
12:28:57 PM: Build was terminated: Build script returned non-zero exit code: 1
12:28:58 PM: Failing build: Failed to build site
12:28:58 PM: Finished processing build request in 8.110559255s

我试图通过更新节点模块来调试它,但错误无法解决

这个问题是由于版本冲突引起的。所以尝试下面的命令来正确安装所有依赖项,

npm install --legacy-peer-deps

这意味着你的React版本(18)与React -alert版本(16.8.1或17)不兼容。https://www.npmjs.com/package/react-alert#user-content-peer-dependencies
所以我的建议是:如果这个包是必要的,那么我建议将你的React版本降级到17或16.8.1,并在部署之前在你的本地环境中测试它。如果这不起作用,那么删除node_modules文件夹并重新安装所有包。

最新更新