laravel-mix: "chunk.sortModules is not a function"

  • Laravel Mix Version: 1.2.0
  • Node Version: 8.1.2
  • NPM Version: 5.2.0
  • OS: LMDE 2 Betsy

Description:

When running mix.sass() it seems to fail with the exception message TypeError: chunk.sortModules is not a function (stack trace below).

Steps To Reproduce:

Have a sass file and run mix.sass().

Stack trace:

advanced chunk optimization/home/user/project/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:188
            chunk.sortModules();
                  ^

TypeError: chunk.sortModules is not a function
    at /home/user/project/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
    at /home/user/project/node_modules/laravel-mix/node_modules/async/dist/async.js:3083:16
    at eachOfArrayLike (/home/user/project/node_modules/laravel-mix/node_modules/async/dist/async.js:1003:9)
    at eachOf (/home/user/project/node_modules/laravel-mix/node_modules/async/dist/async.js:1051:5)
    at Object.eachLimit (/home/user/project/node_modules/laravel-mix/node_modules/async/dist/async.js:3145:5)
    at Compilation.<anonymous> (/home/user/project/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:184:27)
    at Compilation.applyPluginsAsyncSeries (/home/user/project/node_modules/tapable/lib/Tapable.js:142:13)
    at Compilation.seal (/home/user/project/node_modules/webpack/lib/Compilation.js:551:7)
    at Compiler.<anonymous> (/home/user/project/node_modules/webpack/lib/Compiler.js:436:15)
    at /home/user/project/node_modules/tapable/lib/Tapable.js:225:11
    at Compilation.<anonymous> (/home/user/project/node_modules/webpack/lib/Compilation.js:444:10)
    at /home/user/project/node_modules/webpack/lib/Compilation.js:420:12
    at /home/user/project/node_modules/webpack/lib/Compilation.js:332:10
    at /home/user/project/node_modules/async/lib/async.js:52:16
    at done (/home/user/project/node_modules/async/lib/async.js:246:17)
    at /home/user/project/node_modules/async/lib/async.js:44:16
    at /home/user/project/node_modules/webpack/lib/Compilation.js:332:10
    at /home/user/project/node_modules/async/lib/async.js:52:16
    at done (/home/user/project/node_modules/async/lib/async.js:246:17)
    at /home/user/project/node_modules/async/lib/async.js:44:16
    at /home/user/project/node_modules/webpack/lib/Compilation.js:332:10
    at /home/user/project/node_modules/async/lib/async.js:52:16
    at done (/home/user/project/node_modules/async/lib/async.js:246:17)
    at /home/user/project/node_modules/async/lib/async.js:44:16
    at /home/user/project/node_modules/webpack/lib/Compilation.js:332:10
    at /home/user/project/node_modules/async/lib/async.js:52:16
    at Object.async.forEachOf.async.eachOf (/home/user/project/node_modules/async/lib/async.js:236:30)
    at Object.async.forEach.async.each (/home/user/project/node_modules/async/lib/async.js:209:22)
    at Compilation.addModuleDependencies (/home/user/project/node_modules/webpack/lib/Compilation.js:192:8)
    at Compilation.processModuleDependencies (/home/user/project/node_modules/webpack/lib/Compilation.js:177:7)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 23

Commits related to this issue

Most upvoted comments

I came across the same problem, and after revert the plugin to older version solved the problem

npm i extract-text-webpack-plugin@2.1.2

I had such a problem when I installed the extract-text-webpack-plugin@3 with the webpack@2. Then I sync versions and it error gone.

Ridiculous

Okay, got this working. Not sure exactly what the issue is but I had to update my NPM dependencies. Need to update your package.json to include a bunch of loaders and the latest version of webpack like this:

    "babel-loader": "^7.1.1",
    "css-loader": "^0.28.4",
    "file-loader": "^0.11.2",
    "laravel-mix": "^1.2.0",
    "postcss-loader": "^2.0.6",
    "style-loader": "^0.18.2",
    "vue-loader": "^13.0.1",
    "webpack": "^3.2.0"

Don’t know why as it should just be included in the Laravel Mix dependencies which it is but for some reason failing to find/use them. Once you install those packages it should run fine again.

I had this problem as well but I accidentally installed webpack 2.2.0 manually (had to test something).

When I removed my own webpack dependency and let laravel-mix install it automatically everything went fine. I think when you remove your webpack entry, reinstall everything, you should not get any errors.

I see that you are using npm 5.2.0, you may want to switch back to npm 5.1.0 because there is something happening with flattening peer dependencies that will be reverted in the next release of npm.

https://github.com/npm/npm/issues/17717 https://github.com/JeffreyWay/laravel-mix/issues/983

This worked for me. Used yarn instead

rm -rf node_modules
brew install yarn
yarn
yarn run dev

Another solution is:

npm install --save webpack
npm run dev

I can’t reproduce this. Can you do rm -rf node_modules && npm install and see if that changes your output?

I got the same issue and I upgraded my webpack to 3.4…1 then it was fine.

webpack 2 requires special versions of extract-text-webpack-plugin maybe you do not have that version of the plugin. https://github.com/webpack-contrib/extract-text-webpack-plugin