'mix' 在 Laravel 8 新安装中未被识别为内部或外部命令

'mix' is not recognized as an internal or external command in Laravel 8 new installation

我安装了一个新的 Laravel 8 应用程序,然后 运行...

npm install

之后,我运行...

npm run dev

我收到以下错误。

'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\_logs21-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\_logs21-01-18T17_03_24_980Z-debug.log

您可能需要安装最新版本的 Laravel Mix。

npm install laravel-mix@latest --save-dev

如果您是 windows 用户,试试这个:

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

然后 :

npm cache verify

当您的缓存保留以前的 files.Clear 缓存并再次安装 npm 时会发生这种情况

npm cache clean --force

然后:

npm install

npm fix audit

然后:

npm run development

package.json 要求您 运行 mix-watch 命令但它不起作用

一个对我有用的简单修复是 运行ning npm 运行 watch it worked for me laravel 8 project

我的问题已按照以下步骤解决

 npm install --g laravel-mix

npm install --g webpack-cli

只需安装最新版本的 laravel mix 即可支持版本 8

npm install laravel-mix@latest --save-dev
npm install laravel-mix@latest --save-dev