npm npx安装时显示错误

enyaitl3  于 11个月前  发布在  其他
关注(0)|答案(3)|浏览(129)

npx安装时出现错误,请帮助我解决这个问题。我的nodejs版本是v16.14.2,npm版本是8.5.0

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

added 1354 packages in 1m

171 packages are looking for funding
run `npm fund` for details

Initialized a git repository.

Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"<18.0.0" from @testing-library/[email protected]
npm ERR! node_modules/@testing-library/react
npm ERR!   @testing-library/react@"^12.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 /home/psn/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/psn/.npm/_logs/2022-04-12T07_12_21_032Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing- 
library/react@^12.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed

字符串

whhtz7ly

whhtz7ly1#

听起来像是你在一个已经包含react的项目中运行npx create-react-app命令。请尝试运行npm install
如果这不起作用,请尝试删除node_modules文件夹并再次运行npm install

vd8tlhqk

vd8tlhqk2#

您可以尝试以下操作:
1.删除node_modulespackage-lock.json
1.运行npm i web-vitals --save-dev
1.运行npm install

vi4fp9gy

vi4fp9gy3#

如果你试图创建一个项目(无论是next还是react),并且有一些类似的错误类型。尝试使用以下命令重新安装npx。这对我来说很有效。

npm i -g npx

字符串

相关问题