npm run dev in Laravel cannot find vite.js
Error: Cannot find module 'C:\vite\bin\vite.js'Short answer
The dev script runs the vite command from node_modules. If that file is missing, npm install did not finish, was never run, or the command runs outside the project root. Run npm install in the folder that holds package.json, and use a Node.js version Vite supports.
Fix it fast
1Find out which cause you have
Check that you are in the Laravel project root and that Vite is installed there.
node -v ls package.json node_modules/vite2Match what you see, then jump to its fix
- 1
node_modules is missing, or node_modules/vite does not exist.Frontend dependencies were never installed or were interruptedFix - 2
node -v shows an old version, and npm install prints engine warnings.The Node.js version is too old for ViteFix - 3
ls package.json finds nothing in the current folder.The command runs from a folder that is not the project rootFix
- 1
What does the error look like?
Error: Cannot find module 'C:\vite\bin\vite.js'npm run dev exits right after starting, with a module error
Cause 1 of 3
Frontend dependencies were never installed or were interrupted
1Check
A fresh Laravel project ships a package.json with Vite and the Laravel plugin, but you still have to run npm install.
npm ls vite laravel-vite-plugin2Fix
Install the dependencies from the project root. If a half-finished install left a broken folder, remove node_modules first.
rm -rf node_modules
npm install3Verify
The dev server starts.
npm run devConfirmed by laravel.com
Cause 2 of 3
The Node.js version is too old for Vite
1Check
Vite's guide requires Node.js 20.19+ or 22.12+.
node -v2Fix
Install a supported Node.js version from the official site or a version manager, then reinstall.
nvm install 22
nvm use 22
npm install3Verify
Run the dev script again.
npm run devConfirmed by vite.dev
Cause 3 of 3
The command runs from a folder that is not the project root
1Check
Laravel keeps package.json and vite.config.js in the project root, and the scripts depend on that.
pwd2Fix
Change into the project root and run the script there.
cd /path/to/your-laravel-app
npm run dev3Verify
Vite prints its local dev server address.
npm run devConfirmed by laravel.com
How do I stop it coming back?
- Run npm install after every git clone or composer create-project.
- Pin the Node.js version in .nvmrc.
- Keep node_modules out of Git and rely on the lock file.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Web apps
Vite cannot read your vite.config file
Cannot find module
Vite loads vite.config as a file in its own right, and it must be detected as ESM by Node.js if it uses import and export.
3 causes, each with a fixBack end
Laravel mix() fails with 'The Mix manifest does not exist'
The Mix manifest does not exist.
The mix() helper reads mix-manifest.json to find the hashed asset name, and that file only appears after Mix has compiled your assets.
2 causes, each with a fixBack end
Laravel mix() throws Unable to locate Mix file
Unable to locate Mix file: /css/app.css.
This error means mix-manifest.json exists but has no entry for the path you passed to mix().
4 causes, each with a fixBack end
npm run production fails in Laravel Mix with an unknown --hide-modules option
Unknown argument: --hide-modules
The scripts in your package.json were written for Mix 5, which called webpack directly with flags such as --hide-modules.
3 causes, each with a fixBack end
Laravel npm run dev says the mix command was not found
Command "mix" not found when running npm run dev
The mix program comes from the laravel-mix package.
3 causes, each with a fixBack end
Browser does not reload when I save a Blade file under Vite
CSS and JavaScript hot update, but view changes need a manual refresh
Vite only reloads the page for Blade files when the Laravel plugin's refresh option is on.
3 causes, each with a fix