Maaz Zindani

Loading the index…

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

Laravel npm run dev says the mix command was not found

ErrorCommand "mix" not found

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

  • Applies to Laravel 12, Laravel Mix 6, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

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

    1. 1There is no node_modules folder, or it is empty, right after cloning or pulling the project.Dependencies were never installed in this folderFix
    2. 2The scripts call mix, but laravel-mix is missing from devDependencies.package.json does not list laravel-mixFix
    3. 3package.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

What does the error look like?

  • Command "mix" not found
  • Command "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 -3

2Fix

Install the dependencies listed in package.json, then run the script again.

npm install
npm run dev

3Verify

The script starts the Mix build.

npx mix

Confirmed by laravel-mix.com

Did this fix it?

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

2Fix

Add Mix as a dev dependency and keep webpack.mix.js in the root.

npm install laravel-mix --save-dev

3Verify

Compile with npx mix.

npx mix

Confirmed by laravel-mix.com

Did this fix it?

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>&1

2Fix

Use the Vite scripts. If an old tutorial told you to run mix, ignore it for this project.

npm install
npm run dev

3Verify

The Vite development server starts and prints its local address.

npm run build

Confirmed by laravel.com

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

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