Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm run watch says the script is missing in a Laravel project

Errornpm 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.

  • Applies to Laravel 12, Laravel Mix 6, Vite, npm 10 and 11, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.json
  2. 2Match what you see, then jump to its fix

    1. 1package.json lists vite and laravel-vite-plugin, and the scripts are dev and buildThe project uses Vite, which has no watch scriptFix
    2. 2package.json lists laravel-mix, and scripts has no watch entry or only old onesThe project uses Laravel Mix but its scripts block lacks watchFix

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.json

2Fix

Start the Vite dev server instead of watch. It rebuilds on save and refreshes the page.

npm run dev
# production assets
npm run build

3Verify

The dev server prints a local URL and keeps running.

npm run dev

Confirmed by laravel.com

Did this fix it?

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.json

2Fix

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 watch

Confirmed by laravel-mix.com

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.