Laravel npm run dev says the mix command was not found
Command "mix" not foundShort answer
The mix program comes from the laravel-mix package. If it is not installed in this project, npm cannot find the command. Run npm install, make sure laravel-mix is in package.json, and use npx mix. New Laravel projects use Vite, so there the scripts are npm run dev and npm run build instead.
Fix it fast
1Find out which cause you have
Check whether the project depends on Mix at all, and whether the install step ran.
grep -n -E "laravel-mix|\"vite\"" package.json ls node_modules | head -32Match what you see, then jump to its fix
- 1
There is no node_modules folder, or it is empty, right after cloning or pulling the project.Dependencies were never installed in this folderFix - 2
The scripts call mix, but laravel-mix is missing from devDependencies.package.json does not list laravel-mixFix - 3
package.json lists vite and laravel-vite-plugin, and there is a vite.config.js instead of webpack.mix.js.The project uses Vite, not MixFix
- 1
What does the error look like?
Command "mix" not foundCommand "mix" not found when running npm run dev
Cause 1 of 3
Dependencies were never installed in this folder
1Check
Mix provides a command-line program called mix, and its installation steps start with npm install. Without that step the program does not exist.
ls node_modules/laravel-mix 2>&1 | head -32Fix
Install the dependencies listed in package.json, then run the script again.
npm install
npm run dev3Verify
The script starts the Mix build.
npx mixConfirmed by laravel-mix.com
Cause 2 of 3
package.json does not list laravel-mix
1Check
The installation guide adds Mix as a dev dependency with npm install laravel-mix --save-dev, and a webpack.mix.js file in the project root.
grep -n "laravel-mix" package.json; ls webpack.mix.js2Fix
Add Mix as a dev dependency and keep webpack.mix.js in the root.
npm install laravel-mix --save-dev3Verify
Compile with npx mix.
npx mixConfirmed by laravel-mix.com
Cause 3 of 3
The project uses Vite, not Mix
1Check
Current Laravel uses Vite for asset bundling. Its scripts are run with npm run dev for the development server and npm run build for production assets.
ls vite.config.* webpack.mix.js 2>&12Fix
Use the Vite scripts. If an old tutorial told you to run mix, ignore it for this project.
npm install
npm run dev3Verify
The Vite development server starts and prints its local address.
npm run buildConfirmed by laravel.com
How do I stop it coming back?
- Run npm install after every clone and after every change to package.json.
- Follow the asset docs that match your Laravel version; tutorials for Mix do not apply to Vite projects.
- Do not install Mix globally to silence the error; keep it in the project.
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
Back 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 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
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 fixBack end
npm run dev in Laravel cannot find vite.js
npm run dev exits right after starting, with a module error
The dev script runs the vite command from node_modules.
3 causes, each with a fixBack end
Laravel says Vite manifest not found at public/build/manifest.json
Vite manifest not found at: /var/www/app/public/build/manifest.json
Laravel's @vite directive looks for a running dev server first, then for a built manifest file.
3 causes, each with a fix