62

I have installed a new Laravel 8 application, and then I ran...

npm install

Afterward, I ran...

npm run dev

I get the following error.

'mix' is not recognized as an internal or external command


> @ dev E:\wamp64\www\Laravel8Projects\Laravel_Livewire_JetStream_Projects\jetstream_blog
> npm run development


> @ development E:\wamp64\www\Laravel8Projects\Laravel_Livewire_JetStream_Projects\jetstream_blog
> mix

'mix' is not recognized as an internal or external command, operable
program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm
ERR! @ development: `mix` npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the @ development script. npm ERR! This is probably not a
problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!    
C:\Users\HP\AppData\Roaming\npm-cache\_logs\2021-01-18T17_03_24_944Z-debug.log
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ dev: `npm run
development` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @
dev script. npm ERR! This is probably not a problem with npm. There is
likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!    
C:\Users\HP\AppData\Roaming\npm-cache\_logs\2021-01-18T17_03_24_980Z-debug.log
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Spiral
  • 917
  • 1
  • 9
  • 15

7 Answers7

137

Likely you need to install the latest version of Laravel Mix.

npm install laravel-mix@latest --save-dev
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
28

It will happen when your cache holds previous files.Clear the cache and install the npm again

npm cache clean --force

then:

npm install

npm fix audit

then:

npm run development
Emtiaz Zahid
  • 2,645
  • 2
  • 19
  • 35
2

my problem was solved by following these steps

 npm install --g laravel-mix

npm install --g webpack-cli
  • 2
    Installing webpack globally is not recommended https://webpack.js.org/guides/installation/#global-installation. `Note that this is [webpack global installation] not a recommended practice. Installing globally locks you down to a specific version of webpack and could fail in projects that use a different version` – Ihar Aliakseyenka Jul 02 '21 at 13:42
  • 1
    I resolved installing laravel-mix globally. Probably you should remove the 3rd line anyway – realtebo Sep 29 '21 at 08:13
0

First delete node_modules directory and run below command one be one

npm cache clean --force

npm install

npm install --g laravel-mix

npm install --g webpack-cli

npm run development
nacho
  • 531
  • 9
  • 26
Ecs
  • 1
  • 1
-1

NPM INSTALL it will repair it It hapenned because you have some stuff installed after previous NMP I

So, in any strange situation - NPM INSTALL again)

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 14 '23 at 20:37
-4

package.json requires you to run mix-watch command but it doesnt work

a simple fix that worked for me is running npm run watch it worked for me laravel 8 project

-5

If you are a windows user try this :

C:\Users{{your-username}}\AppData\Roaming\npm-cache

then :

npm cache verify
Syscall
  • 19,327
  • 10
  • 37
  • 52