Laravel:NPM运行表错误(Laravel: npm run watch Error)

2019-09-30 14:36发布

我工作的一个项目,我运行“故宫运行手表”,我得到这个错误。 我是正常工作,但所有的突然我得到这个错误!

> @ watch C:\projects\tests\blog
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development                                          
node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --     
config=node_modules/laravel-mix/setup/webpack.config.js

undefined:1



SyntaxError: Unexpected token

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe"        
"C:\\Users\\Bruno\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
npm ERR! node v6.10.0
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `node node_modules/cross-env/dist/bin/cross-env.js        
NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script 'node node_modules/cross-  env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/cross-env/dist/bin/cross-env.js        
NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Bruno\AppData\Roaming\npm-cache\_logs\2017-03-20T13_06_27_111Z-debug.log

我该怎么办?

Answer 1:

如果你正在开发一个Windows系统上,或者你是一个Windows主机系统上运行的虚拟机,你可能需要运行故宫安装并启用开关--no斌链接命令:

安装使用下面的命令:

npm install --no-bin-links

及后运行以下命令:

npm run watch-poll

来源5.4

源为<= 5.3



Answer 2:

我只是简单的删除内置的CSS和JS文件以及与mix-manifest.json文件。 事情后来工作



Answer 3:

对我来说,只是删除了mix-manifest.json文件。 那时npm run watch-poll

package.json脚本。

"scripts": {
    "dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },

从XAMPP壳运行laravel(窗口7)



Answer 4:

注意:请确保您有安装了最新版本的Node.js和NPM的。

  • 清除NPM的缓存: sudo npm cache clean -f
  • 安装所谓的'N' : sudo npm install -gn
  • 安装最新的稳定版本的Node.js: sudo n stable

或者选择一个特定的版本,并安装这样的:

sudo n (wanted node version)

你可以得到有关如何打开一个问题,这个项目的信息: npm bugs

它在日志输出做字面描述...



文章来源: Laravel: npm run watch Error