我正在尝试使用Laravel Mix编译Webpack配置文件。
在Laracasts Vue 2系列上的webpack插曲之后,
// Scripts
"scripts": {
"dev": "node node_modules/cross-env/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"
},
....
// mix
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version();
当我运行$ npm run dev时,出现错误:
npm ERR! Exit status 1
npm ERR! Failed at the @ dev script 'node node_modules/cross-env/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'.
// Running
npm ERR! node v4.4.5
npm ERR! npm v2.15.5
// The error points to
let extractPlugin = new plugins.ExtractTextPlugin(
/Users/User/Code/project/node_modules/laravel-mix/setup/webpack.config.js:126
问题似乎是更新了Node.js依赖项:https://github.com/JeffreyWay/laravel-mix/issues/264
如何更新Node.js依赖项?
我在尝试:
$ brew upgrade node : Error = node not installed
$ node -v = 2.15.5
$ npm -v = 4.4.5
$ brew install node // installs but throws error
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
Possible conflicting files are:
/usr/local/bin/node
...
**$ brew upgrade node // says node 7.5.0 already installed**
$ npm run dev // same error
$ node -v = 4.4.5
我还运行了已安装的$ brew install节点,但出现错误:
要强制链接并覆盖所有冲突的文件,请执行以下操作:
brew link --overwrite node
列出所有将被删除的文件:
brew link --overwrite --dry-run node
最佳答案
您可以在laravel项目中删除节点模块文件夹。
在运行之后:
npm install - g npm
此命令将重新安装带有升级节点文件的节点模块文件夹。接下来,您可以尝试运行
npm run dev
你也可以跑npm update
更新您的节点希望这个答案会有所帮助