“npm run watch”不起作用并返回错误,提示“缺少“Watch””

Wak*_*med 10 npm laravel

在我的新 Laravel 项目中添加 Tailwind 模板后,我尝试运行npm run watch但它不起作用,因此模板也无法正确加载。

$ npm run watch                                                       
npm ERR! Missing script: "watch"                                                                
npm ERR!                                                                                        
npm ERR! To see a list of scripts, run:                                                         
npm ERR!   npm run                                                                              
                                                                                                
npm ERR! A complete log of this run can be found in:                                            
npm ERR!     C:\Users\U-S-E-R\AppData\Local\npm-cache\_logs\2022-07-27T18_05_36_192Z-debug-0.log
Run Code Online (Sandbox Code Playgroud)

这是错误截图

小智 39

更新您的 package.json 文件。

...
    "scripts": {
    "dev": "vite",
    "build": "vite build",
    "watch": "vite build --watch"
},
...
Run Code Online (Sandbox Code Playgroud)

参考:https://vitejs.dev/guide/build.html#rebuild-on-files-changes https://laracasts.com/discuss/channels/vite/equivalent-of-vite-watch?reply=809106

现在尝试运行

npm run dev
npm run watch
Run Code Online (Sandbox Code Playgroud)