Edvard Åkerberg
Edvard Åkerberg

Reputation: 2191

Laravel npm run dev returns TypeError: chunk.sortModules is not a function

When I try to run npm run dev, I get this error. This is a fresh install, and I have it working with the same setup in another folder. I get the same error on another computer.

Versions NPM: 5.3.0 Node: 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

Upvotes: 1

Views: 2231

Answers (3)

user9944079
user9944079

Reputation: 1

First, remove the webpack plugin. Then install and build yarn using the following steps:

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

Upvotes: 0

Miguel Salas
Miguel Salas

Reputation: 701

the issue seems to be related to difference in packages, just today I was updating webapacker version 3 which uses webpack version 3 in rails app and I was getting this same error. The issue stoped when I updated this packages to this versions in the package.json file: "sass-loader": "^6.0.6" "babel-loader": "7.1.2" "webpack": "^3.6.0" Thanks to the suggestion of this guy: https://github.com/rails/webpacker/issues/852#issuecomment-331764386 I suggest that if you are using these packages you change to these versions to see if it works for you also.

Upvotes: 4

Edvard &#197;kerberg
Edvard &#197;kerberg

Reputation: 2191

This worked for me. When I used Yarn instead.

rm -rf node_modules
brew install yarn
yarn
yarn run dev

Upvotes: 0

Related Questions