Laravel:npm run watch 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42904652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel: npm run watch Error
提问by Bruno Erceg
I was working on a project and I run 'npm run watch' and I got this error. I was working normally but all of sudden I got this error!
我正在做一个项目,我运行“npm run watch”,但出现了这个错误。我正在正常工作,但突然间我收到了这个错误!
> @ 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\_logs17-03-20T13_06_27_111Z-debug.log
What should I do?
我该怎么办?
回答by Jo?o Mantovani
If you are developing on a Windows system or you are running your VM on a Windows host system, you may need to run the npm install command with the --no-bin-links switch enabled:
如果您在 Windows 系统上开发或在 Windows 主机系统上运行 VM,则可能需要在启用 --no-bin-links 开关的情况下运行 npm install 命令:
Install using this command:
使用以下命令安装:
npm install --no-bin-links
And run this after:
并在之后运行:
npm run watch-poll
回答by OverCoder
I just simply deleted built CSS and JS files as well as the mix-manifest.json
file. Things worked afterwards
我只是简单地删除了构建的 CSS 和 JS 文件以及mix-manifest.json
文件。事后奏效
回答by Ikechi
For me just deleted the mix-manifest.json
file. Then did npm run watch-poll
对我来说只是删除了mix-manifest.json
文件。然后做了npm run watch-poll
My package.json
script.
我的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"
},
Running laravel from xampp shell (windows 7)
从 xampp shell (windows 7) 运行 laravel
回答by King Reload
Note: Make sure you have the latest version of node.js and npm installed.
注意:确保您安装了最新版本的 node.js 和 npm。
- Clear NPM's cache:
sudo npm cache clean -f
- Install called 'n':
sudo npm install -g n
- Install latest stable Node.js version:
sudo n stable
- 清除 NPM 的缓存:
sudo npm cache clean -f
- 安装名为 'n':
sudo npm install -g n
- 安装最新的稳定 Node.js 版本:
sudo n stable
Alternatively pick a specific version and install like this:
或者选择一个特定版本并像这样安装:
sudo n (wanted node version)
sudo n (wanted node version)
You can get information on how to open an issue for this project with: npm bugs
您可以通过以下方式获取有关如何为此项目打开问题的信息: npm bugs
It's literally described in the log output what to do...
它在日志输出中逐字描述了要做什么......