Laravel Mix:更新 Node.js 依赖项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42068686/
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 Mix: Update a Node.js dependency
提问by Dazzle
I am trying to compile webpack configuration files with Laravel Mix.
我正在尝试使用 Laravel Mix 编译 webpack 配置文件。
Following webpack episode on Laracasts Vue 2 series,
在 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();
When I run $ npm run dev, I get an error:
当我运行 $ 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
The issue seems to be update a Node.js dependency: https://github.com/JeffreyWay/laravel-mix/issues/264
问题似乎是更新 Node.js 依赖项:https: //github.com/JeffreyWay/laravel-mix/issues/264
How do I update the Node.js dependency?
如何更新 Node.js 依赖项?
I am trying:
我在尝试:
$ 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
I also ran $ brew install node which installed, but I got an error:
我还运行了 $ brew install node which installed,但出现错误:
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'
错误:该
brew link
步骤未成功完成。
公式已构建,但未符号链接到 /usr/local。
无法符号链接 bin/node。
目标 /usr/local/bin/node
已经存在。您可能想要删除它: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
回答by Dazzle
I installed Node.js again from nodejs.org, rewriting old files.
我从 nodejs.org 再次安装了 Node.js,重写了旧文件。
However this actually downgraded npm from 4.4.5 to 4.1.2... Node.js was 2.15.5 and is now 7.5.0.
然而,这实际上将 npm 从 4.4.5 降级到 4.1.2……Node.js 是 2.15.5,现在是 7.5.0。
I also had to install a few modules: $ npm install autoprefixer
我还必须安装一些模块: $ npm install autoprefixer
$ npm run dev // works now