How to Fix a Broken Rollup Build with a Simple package.json Override
If you've ever seen a cryptic error pop up during your build process, you'll know the feeling: frustration mixed with just a hint of panic. In this case, the culprit was a specific version of Rollup. After some digging, the fix turned out to be surprisingly straightforward—though it did require a manual override. Here's exactly what happened and how to fix it yourself.
What caused the Rollup issue?
The build failure was triggered by an incompatibility introduced in a more recent version of Rollup. While Rollup is a fantastic module bundler, like any tool, it can occasionally ship a patch that breaks existing workflows or third-party plugins. In our case, the build pipeline couldn't handle the newer release, causing the entire process to halt.
The solution? Pin Rollup to a known working version using a package override. This ensures your build environment uses a safe, stable release regardless of what your dependencies request.
Step-by-step fix
Add the override to
package.json
Open your project'spackage.jsonfile and insert the following block at the bottom of the JSON object (or alongside any existing overrides):{ "overrides": { "rollup": "4.15.0" } }Reinstall dependencies
Run this command in your terminal to apply the override and reinstall affected packages:npm installRebuild your project
Now trigger the build process again. Since Rollup is pinned to a compatible version, it should complete without the earlier error:npm run build- Deploy the fixed build
Once the build succeeds, deploy as usual. The override won't affect your runtime code—it only ensures the bundler itself stays at a reliable version.
One caveat to keep in mind
- Overrides are a last resort. They bypass the normal version resolution, which can hide deeper dependency issues or prevent important security patches. Use them sparingly and document why the override exists.
- Check regularly whether the upstream issue has been resolved. When a new Rollup version fixes the incompatibility, you can remove the override and update normally.
Final thoughts
While it's never fun to manually intervene in your dependency tree, sometimes it's the quickest path to a working build. The override approach is simple, effective, and lets you get back to shipping code. Just remember to revisit it after a few weeks so you don't get stuck on an outdated Rollup version indefinitely.
If you've encountered a similar Rollup issue, try this fix—it may save you hours of debugging. And if you have another workaround, share it in the comments below.