大家好,今天我有一个问题,这是当我安装laravel用户界面与React和传递到步骤npm安装一个错误发生,所以下面你会发现错误
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\E495\AppData\Local\npm-cache\_logs\2023-01-16T08_08_36_872Z-debug-0.log
PS C:\Users\E495\Desktop\laravel-simple-crud> npm install
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: vite@4.0.4
npm ERR! node_modules/vite
npm ERR! dev vite@"^4.0.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vite@"^3.0.0" from @vitejs/plugin-react@2.2.0
npm ERR! node_modules/@vitejs/plugin-react
npm ERR! dev @vitejs/plugin-react@"^2.2.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\E495\AppData\Local\npm-cache\eresolve-report.txt for a full report.
所以在错误的上面和下面你会发现我的package.json
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@popperjs/core": "^2.11.6",
"@tailwindcss/forms": "^0.5.2",
"@vitejs/plugin-react": "^2.2.0",
"alpinejs": "^3.4.2",
"autoprefixer": "^10.4.2",
"axios": "^1.1.2",
"bootstrap": "^5.2.3",
"laravel-vite-plugin": "^0.7.2",
"lodash": "^4.17.19",
"postcss": "^8.4.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "^1.56.1",
"tailwindcss": "^3.1.0",
"vite": "^4.0.4"
}
}
我尝试读取错误并将vite版本更改为4.0.4,但没有任何结果
1条答案
按热度按时间3pvhb19x1#
您应该能够使用以下命令来解决此错误:
This previous post详细介绍了
--legacy-peer-deps
在这里的作用。简而言之,
@vitejs/plugin-react
(特别是作为开发依赖项的版本2.2.0
)列出了vite的旧版本(vite@"^3.0.0"
)作为其对等依赖项之一,但它发现安装了较新的vite@"^4.0.4"
。(如果你好奇,可以查看链接的帖子或谷歌),NPM不能解决这种对等依赖冲突,因为它通常会解决我们更熟悉的常规依赖和开发依赖。--legacy-peer-deps
通过绕过对等依赖项自动安装来解决此问题。