Laravel Mix:更新Node.js依赖项

Daz*_*zle 12 node.js laravel webpack vuejs2 laravel-mix

我正在尝试使用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();
Run Code Online (Sandbox Code Playgroud)

当我运行$ 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
Run Code Online (Sandbox Code Playgroud)

问题似乎是更新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
Run Code Online (Sandbox Code Playgroud)

我还运行了安装的$ brew安装节点,但是我收到了一个错误:

错误:该brew link步骤未成功完成.
建立了公式,但没有符号链接到/ usr/local.
无法符号链接bin/node.
目标/ usr/local/bin/node
已存在.您可能想要删除它:
rm '/usr/local/bin/node'

强制链接并覆盖所有冲突文件:

brew link --overwrite node
Run Code Online (Sandbox Code Playgroud)

列出要删除的所有文件:

brew link --overwrite --dry-run node
Run Code Online (Sandbox Code Playgroud)

Daz*_*zle -3

我再次从nodejs.org安装了Node.js,重写了旧文件。

然而,这实际上将 npm 从 4.4.5 降级到 4.1.2...Node.js 是 2.15.5,现在是 7.5.0。

我还必须安装一些模块:$ npm install autoprefixer

$ npm run dev // works now
Run Code Online (Sandbox Code Playgroud)

  • 必须更新节点和npm,然后有一堆缺少的依赖项,例如autoprefixer...它告诉我每个人都下载缺少的只是npm install的问题缺少依赖项据我所知只有2-3个。你明白了吗? (2认同)