laravel-mix: Laravel Mix breaks with css-loader 6.x

After running npm update this morning, I got a bunch of errors when trying to build. After researching things, it appears that when I ran npm update, something updated webpack’s css-loader package from 5.x to 6.x which has a lot of breaking changes.

I’m not sure if Laravel Mix allowed npm update to update css-loader, or something else, but I’m wondering if anyone has a hotfix in the meantime?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 27

Most upvoted comments

Nah, that shouldn’t be an issue. In the mean time you can explicitly add "css-loader": "^5.2" to your projects package.json file and that should hopefully resolve it.

@JeffreyWay, sorry for the delay. Can confirm that build passes fine after the upgrade to v6.0.27.

We include CSS loader 5.x: https://github.com/JeffreyWay/laravel-mix/blob/420d5d642e3c9a8752d396e75283fe27f0c41e28/package.json#L67

Are you possibly overriding anything in your package.json?

@maximal @jacobgraf Can you guys bump to 6.0.27 and let us know if you’re still seeing issues?

I opened a PR. I still need to test it myself on a few different minimal projects but I can’t at the moment.

Thank you!! You guys saved my hide! I had no idea why my npm compilations suddenly were going haywire today. All kinds of module build errors on all of my Vue components and sass/css compilations, e.g.,

Module build failed (from ./node_modules/css-loader/dist/cjs.js): ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.

ERROR in ./resources/assets/sass/app.scss Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): ModuleBuildError: Module build failed (from ./node_modules/css-loader/dist/cjs.js):

Locking css-loader to 5.2.7 fixes it. Phew.

MacOS Catalina 10.15.7 Node 12.20.1 npm 7.14.0 Laravel-mix 6.0.25

Not sure what happened here, but I’ve been banging my head against the wall on this all morning. Finally ate lunch and came back with a clear head - found that cssloader had updated to 6.0.0 ~19 hours ago with a bunch of breaking changes.

running npm install --save-dev css-loader@5.2.7 seems to do the trick for now, and builds are successful.