繁体   English   中英

执行 npm install && npm run dev - Vite - Laravel UI React 时发生错误

[英]error occured when do npm install && npm run dev - Vite - Laravel UI React

大家好,今天我遇到了一个问题,当我安装laravel ui 和 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但没有任何结果

您应该能够使用以下命令解决此错误:

npm install --legacy-peer-deps

一篇文章详细介绍了--legacy-peer-deps在这里做什么。

简而言之, @vitejs/plugin-react (特别是你作为开发依赖的版本2.2.0 )已经列出了一个旧版本的 vite( vite@"^3.0.0" )作为它的对等依赖之一,但它是找到更新的vite@"^4.0.4"安装。 由于我无法完全解释的原因(如果您好奇,请参阅链接的帖子或谷歌),NPM 无法解决此对等依赖冲突,因为它通常会解决我们更熟悉的常规依赖项和开发依赖项和。 --legacy-peer-deps通过绕过对等依赖自动安装来解决这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM