javascript - error occured when do npm install && npm run dev - Vite - Laravel UI React - Stack Overflow

hello everyone today i had a problem that's when i install laravel ui with react and pass to the s

hello everyone today i had a problem that's when i install laravel ui with react and pass to the step of npm install an error occured so below you will find the error

npm ERR! A plete 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: [email protected]
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/[email protected]
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 mand 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.

so above the error and below you'll find my 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"
    }
}

i try to read the error and change the vite version to 4.0.4 but without any result

hello everyone today i had a problem that's when i install laravel ui with react and pass to the step of npm install an error occured so below you will find the error

npm ERR! A plete 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: [email protected]
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/[email protected]
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 mand 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.

so above the error and below you'll find my 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"
    }
}

i try to read the error and change the vite version to 4.0.4 but without any result

Share Improve this question asked Jan 16, 2023 at 8:26 Achraf HebboulAchraf Hebboul 131 silver badge7 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You should be able to get by this error with the following mand:

npm install --legacy-peer-deps

This previous post goes into detail about what --legacy-peer-deps is doing here.

In short, @vitejs/plugin-react (specifically the version 2.2.0 you have as a dev dependency) has listed an older version of vite (vite@"^3.0.0") as one of its peer dependencies, but it is finding the newer vite@"^4.0.4" installed. For reasons that I can't totally explain (see the linked post or Google if you're curious), NPM is not able to resolve this peer dependency conflict as it usually would for the regular dependencies and dev dependencies that we're more familiar with. --legacy-peer-deps gets around this by bypassing peer dependency auto-installation.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744172797a4561615.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信