我尝试使用vercel部署我的react应用程序,我在终端中执行了每一步,但最后得到错误“Error:Command“npm install”exited with 1”

eh57zj3b  于 5个月前  发布在  React
关注(0)|答案(1)|浏览(64)

以下是有关问题的详细资料:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/typescript
npm ERR!   typescript@"^5.3.3" from the root project
npm ERR!   peer typescript@">= 2.7" from [email protected]
npm ERR!   node_modules/fork-ts-checker-webpack-plugin
npm ERR!     fork-ts-checker-webpack-plugin@"^6.5.0" from [email protected]
npm ERR!     node_modules/react-dev-utils
npm ERR!       react-dev-utils@"^12.0.1" from [email protected]
npm ERR!       node_modules/react-scripts
npm ERR!         react-scripts@"^5.0.1" from the root project
npm ERR!   1 more (tsutils)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from [email protected]
npm ERR! node_modules/react-scripts
npm ERR!   react-scripts@"^5.0.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"^3.2.1 || ^4" from [email protected]
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"^5.0.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /vercel/.npm/_logs/2023-12-07T15_39_01_419Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /vercel/.npm/_logs/2023-12-07T15_39_01_419Z-debug-0.log
Error: Command "npm install" exited with 1

字符串
我已经更新了我的节点,npm,ts到最新版本

ki0zmccv

ki0zmccv1#

让我们检查一下[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)软件包的对等依赖关系:

$ npm view [email protected] peerDependencies
{ react: '>= 16', typescript: '^3.2.1 || ^4' }

字符串
这意味着[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)包需要typescript@^3.2.1typescript@^4作为其对等依赖项。但是您的项目中安装了[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)。使用npm v7+会遇到此错误,请参见对等依赖项
有两种解决方案:
1.将typescript软件包降级为兼容版本。

npm i typescript@^4 -S


1.使用package.json的覆盖配置

"dependencies": {
  "@testing-library/jest-dom": "^5.17.0",
  "@testing-library/react": "^13.4.0",
  "@testing-library/user-event": "^13.5.0",
  "@types/jest": "^27.5.2",
  "@types/node": "^16.18.68",
  "@types/react": "^18.2.42",
  "@types/react-dom": "^18.2.17",
  "react": "^18.2.0",
  "react-dom": "^18.2.0",
  "react-scripts": "5.0.1",
  "typescript": "^5.3.3",
  "web-vitals": "^2.1.4"
},
"overrides": {
  "react-scripts": {
    "typescript": "^5"
  }
},


请参阅相关问题:issues#13080issues#13259

相关问题