npm run watch says the script is missing in a Laravel project
npm ERR! Missing script: "watch"Short answer
npm run watch only works if package.json defines a script named watch. New Laravel apps bundle with Vite and ship dev and build scripts, so use npm run dev instead. A project that really uses Laravel Mix needs the Mix 6 scripts, where watch is mix watch. Run npm run to see what is defined.
Fix it fast
1Find out which cause you have
List the scripts this project defines. Read the names before choosing a cause.
npm run grep -E "vite|laravel-mix" package.json2Match what you see, then jump to its fix
What does the error look like?
npm ERR! Missing script: "watch"npm error Missing script: "watch"
Cause 1 of 2
The project uses Vite, which has no watch script
1Check
Laravel's own docs run the Vite dev server with npm run dev and make a production build with npm run build.
grep -A4 '"scripts"' package.json2Fix
Start the Vite dev server instead of watch. It rebuilds on save and refreshes the page.
npm run dev
# production assets
npm run build3Verify
The dev server prints a local URL and keeps running.
npm run devConfirmed by laravel.com
Cause 2 of 2
The project uses Laravel Mix but its scripts block lacks watch
1Check
Mix 6 expects scripts that call the mix command. If the block was trimmed, or came from an older Mix, watch can be missing.
grep -n "laravel-mix" package.json2Fix
Put the Mix 6 scripts from the upgrade guide into package.json, then run the one you need.
"scripts": {
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"production": "mix --production"
}3Verify
Run watch; it compiles once and then waits for changes.
npm run watchConfirmed by laravel-mix.com
How do I stop it coming back?
- Read the scripts block of package.json on a new project before copying commands from an old tutorial.
- Check whether the project uses Vite or Mix first; tutorials for one do not work on the other.
- Run npm run with no arguments to list the scripts instead of guessing names.
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 start says the script is missing
npm error Missing script: "start"
npm start runs the start script from the nearest package.json.
4 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 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 fix