1 javascript php laravel reactjs vite
大家好,今天我遇到了一个问题,当我使用React 安装 laravel ui并传递到npm install步骤时,发生了错误,所以下面你会发现错误
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.
Run Code Online (Sandbox Code Playgroud)
所以在错误上方和下方你会找到我的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"
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试读取错误并将vite 版本更改为 4.0.4但没有任何结果
您应该能够使用以下命令解决此错误:
npm install --legacy-peer-deps
Run Code Online (Sandbox Code Playgroud)
上一篇文章详细介绍了--legacy-peer-deps这里所做的事情。
简而言之, (特别是您作为开发依赖项的@vitejs/plugin-react版本)已将旧版本的 vite ( ) 列为其对等依赖项之一,但它正在查找已安装的较新版本。由于我无法完全解释的原因(如果您好奇,请参阅链接的帖子或 Google),NPM 无法解决这种对等依赖冲突,就像我们更熟悉的常规依赖项和开发依赖项通常会解决的那样和。通过绕过对等依赖自动安装来解决这个问题。2.2.0vite@"^3.0.0"vite@"^4.0.4"--legacy-peer-deps
| 归档时间: |
|
| 查看次数: |
3139 次 |
| 最近记录: |