node.js - Laravel Mix : Update a Node. js 依赖

标签 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();

当我运行 $ 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 node ,但我得到了一个错误:

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 --overwrite node

列出所有将被删除的文件:

brew link --overwrite --dry-run node

最佳答案

您可以删除 laravel 项目中的 Node 模块文件夹。

之后运行:

npm install - g npm

此命令将使用升级 Node 文件重新安装 Node 模块文件夹。 接下来,您可以尝试运行

npm run dev

你也可以运行

npm update

更新你的 Node

希望这个答案会有所帮助

关于node.js - Laravel Mix : Update a Node. js 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42068686/

相关文章:

javascript - 将 html 标签作为 ejs 变量的值传递

node.js - 如何解决 yarn 生成错误-错误:ENOTEMPTY:目录不为空,rmdir '/frontend/out/node_modules/cacache/node_modules/.bin'

javascript - 对于较新的 Angular 4 项目,使用 Angular-CLI 或仍然使用 webpack

javascript - 将文件合并到 Webpack 的条目中

jquery - 在 Node 中读取和编辑 HTML 文件的 DOM

node.js - 使用 geoNear 时出现 node-mongodb-native 错误

php - Laravel:Eloquent Query Builder 哪里有时间戳?

php - 如何分解键值对并在查询中使用它们

php - 参数 1 已传递,必须是数组类型,给定字符串

webpack publicPath - 使用不同的 url 来重用 bundle