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!