Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

duyn's avatar
Level 7

Laravel-mix is breaking ...

I have an older project still using Laravel-mix for building out the front-end. Just ran into this issue:

Removing node_modules and package-lock.json and rebuilding the front-end does not resolve this missing module.

0 likes
3 replies
LaryAI's avatar
Level 58

Certainly! This is a known issue that can occur when Laravel Mix is used with a version of webpack that removed or restructured internal modules (such as SizeFormatHelpers). This is typical when installing the latest version of webpack on a project that expects an older version.

Root cause:
laravel-mix (typically versions <=6) is not fully compatible with webpack@5 (and above) because certain internal modules have been moved, renamed, or removed.


Solution

1. Check Your Current Versions

Look at your package.json:

  • laravel-mix
  • webpack

For example:

"laravel-mix": "^6.0.0",
"webpack": "^5.0.0"

2. Set Compatible Versions

Laravel Mix 6 is designed to work with webpack 4 by default (webpack 5 support is only partial and requires Mix >=6.0.25, and even then, it can be finicky).

a. Downgrade webpack (Recommended for legacy projects)

Change your dependencies so that you explicitly use webpack 4, for example:

"laravel-mix": "^6.0.6",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"

b. Update if you need webpack 5 support

If you must use webpack 5 (not generally recommended for legacy projects unless absolutely necessary), ensure your laravel-mix is at least ^6.0.25 and run:

npm install webpack@5 webpack-cli@4

But downgrading is more stable.

3. Clean and Reinstall

Remove your old dependencies to ensure a clean install:

rm -rf node_modules package-lock.json
npm install

4. Try Again

Try to run your Mix compile command (e.g., npm run dev).


Example: package.json

{
    "devDependencies": {
        "laravel-mix": "^6.0.6",
        "webpack": "^4.46.0",
        "webpack-cli": "^3.3.12"
    }
}

Extra: If you have to use Webpack 5

If the above (downgrading) is not an option and you want to try with Webpack 5 and the most recent Mix 6.x, you can try this:

"laravel-mix": "^6.0.49",
"webpack": "^5.88.2",
"webpack-cli": "^4.10.0"

But you may encounter other issues!


Summary Table

Mix Version Supported Webpack Stable Webpack CLI
5.x 4.x 3.x
6.x (pre 6.0.25) 4.x 3.x (use 4.x w/ caution)
6.0.25+ 4.x/5.x* 3.x/4.x*

* Use with care; not all features supported/bug-free.


References


In summary: Use webpack@4 and webpack-cli@3 for legacy Laravel Mix projects. This will restore the internal module that is missing.


If you continue to have issues, please post your package.json file here so further advice can be given!

imrandevbd's avatar

Webpack removed SizeFormatHelpers in v5.76.0. Your project probably pulled in the newer webpack automatically, which breaks the BuildOutputPlugin in older Mix releases.

Just bump laravel-mix to ^6.0.49 in your package.json. Jeffrey patched this exact issue a while back so you don't need to downgrade Webpack like the AI suggested.

Wipe your node_modules and package-lock.json, run npm install, and you should be good to go.

duyn's avatar

Thanks, I tried deleting package-lock.json and node_modules but it was still breaking. I ended up having to use my old package-lock.json in production to get it to build so there's some other updated dependency breaking it.

Please or to participate in this conversation.