[英]npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve. When I ran npm install
當我運行“npm install”從克隆的存儲庫安裝依賴項時,我從終端收到以下錯誤。 我用 windows 10
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-scripts@4.0.0
npm ERR! Found: typescript@4.1.3
npm ERR! node_modules/typescript
npm ERR! dev typescript@"4.1.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@4.0.0
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"4.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@3.9.10
npm ERR! node_modules/typescript
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@4.0.0
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"4.0.0" 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! See C:\Users\USER-PC\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER-PC\AppData\Local\npm-cache\_logs\2022-10-04T10_18_32_
即使當我運行npm install --legacy-peer-deps
時,我仍然會遇到同樣的錯誤。 請問什么可能是錯的?
這是我的 package.json 文件中的內容:
}
]
"name": "info-site",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "src/index.js",
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"react-scripts": "4.0.0"
},
"devDependencies": {
"@babel/runtime": "7.13.8",
"typescript": "4.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
該錯誤告訴您react-scripts@4.0.0
支持typescript@^3.2.1
(即 TypeScript >=3.2.1, <4)作為對等依賴項。
您的開發依賴項中有 TypeScript 4(不是 3.2.x),該版本的 react-scripts 不支持,因此解析錯誤。
react-scripts 的當前版本是 5.0.1 ,所以我建議將 react-scripts 升級到該版本(只需將 package.json 中的"4.0.0"
更改為"5.0.1"
)並重試,因為那版本聲明支持 TypeScript 4 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.