I downloaded laravel 9. But new version of laravel is using vite instead of webpack.
composer require laravel/ui
php artisan ui react
this command is working fine. But npm install
command not working
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!
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.
After this error, I found some solution from stackoverflow here is link
So, I installed this command npm install --legacy-peer-deps
this is working fine.
Then I using this @vite(['resources/css/app.css', 'resources/js/app.js'])
in my view.
But my view gives me this error:
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201
at Example.jsx?t=1674104015528:6:11
How to solve it? Please help.