[英]Laravel: npm run watch 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\_logs\2017-03-20T13_06_27_111Z-debug.log
我應該怎么辦?
如果您在 Windows 系統上開發或在 Windows 主機系統上運行 VM,您可能需要運行 npm 安裝命令並啟用 --no-bin-links 開關:
使用此命令安裝:
npm install --no-bin-links
然后運行這個:
npm run watch-poll
我只是簡單地刪除了構建的 CSS 和 JS 文件以及mix-manifest.json
文件。 事情后來奏效了
對我來說,剛剛刪除了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 shell (windows 7)
注意:確保安裝了最新版本的 node.js 和 npm。
sudo npm cache clean -f
sudo npm install -gn
sudo n stable
或者選擇一個特定版本並像這樣安裝:
sudo n (wanted node version)
您可以獲得有關如何為該項目打開問題的信息: npm bugs
它在日志 output 中逐字描述了要做什么......
也試試這個:npm uninstall --save-dev sass-loader
當我嘗試運行命令 npm run dev / npm run watch 時,它運行完美
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.