Laravel npm run dev返回TypeError:chunk.sortModules不是函数

时间:2017-09-04 14:07:25

标签: laravel npm laravel-mix

当我尝试运行npm run dev时,我收到此错误。这是一个全新的安装,我让它在另一个文件夹中使用相同的设置。我在另一台计算机上遇到同样的错误。

版本 NPM:5.3.0 节点:v8.4.0

test ⚑ → npm run dev                                                                                                                                                                                                                                                        master ✗ 2d

> @ dev /Users/myuser/Code/testing/test
> 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

 78% advanced chunk optimization/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188
            chunk.sortModules();
                  ^

TypeError: chunk.sortModules is not a function
    at /Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
    at /Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3083:16
    at eachOfArrayLike (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1003:9)
    at eachOf (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1051:5)
    at Object.eachLimit (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3145:5)
    at Compilation.<anonymous> (/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:184:27)
    at Compilation.applyPluginsAsyncSeries (/Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:206:13)
    at Compilation.seal (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:579:8)
    at /Users/myuser/Code/testing/test/node_modules/webpack/lib/Compiler.js:493:16
    at /Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:289:11
    at _addModuleChain (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:481:11)
    at processModuleDependencies.err (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:452:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ 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`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2017-09-04T13_55_30_770Z-debug.log

3 个答案:

答案 0 :(得分:4)

这个问题似乎与软件包的差异有关,就在今天我正在更新webapacker版本3,它在rails应用程序中使用了webpack版本3,我得到了同样的错误。在package.json文件中将此软件包更新到此版本时,问题仍然存在: "sass-loader": "^6.0.6" "babel-loader": "7.1.2" "webpack": "^3.6.0" 感谢这个家伙的建议:https://github.com/rails/webpacker/issues/852#issuecomment-331764386 我建议如果您使用这些软件包,请更改为这些版本以查看它是否也适用于您。

答案 1 :(得分:0)

这对我有用。当我用Yarn代替时。

rm -rf node_modules
brew install yarn
yarn
yarn run dev

答案 2 :(得分:0)

首先,删除webpack插件。然后使用以下步骤安装并构建yarn

  1. npm install remove-webpack-plugin --save-dev
  2. yarn install
  3. yarn build