Vercel build cannot find @rollup/rollup-linux-x64-gnu
The Vercel build stops with Cannot find module @rollup/rollup-linux-x64-gnu. A Mac-written npm lockfile omitted Rollup's Linux optional dependency. Regenerate the lockfile and check it.
Updated 2026-10-15
The Vercel build log reaches vite build and stops with:
Error: Cannot find module @rollup/rollup-linux-x64-gnu.
npm has a bug related to optional dependencies
(https://github.com/npm/cli/issues/4828).
Please try `npm i` again after removing both package-lock.json and node_modules directory.The stack trace runs through node_modules/rollup/dist/native.js, in requireWithFriendlyError. Your app never imports that module. Rollup does, while it loads the native binary for the machine that is building. Vite projects that still bundle with Rollup 4 hit this on Vercel whenever the lockfile was produced on a Mac and npm dropped the Linux optional dependency.
What the lockfile is missing
Rollup 4 publishes one npm package per platform, and the main rollup package lists them in optionalDependencies. The package for 64-bit Linux with glibc is @rollup/rollup-linux-x64-gnu. There are sibling packages for macOS (darwin-arm64, darwin-x64) and Windows. npm is supposed to install only the one that matches the current machine, and the lockfile is supposed to remember the others so a later install on another OS can select a different one.
npm has a long-running bug, tracked as npm/cli#4828, where optional dependencies for platforms other than the one that ran npm install are left out of package-lock.json. Lovable, Bolt, and a laptop running macOS all produce a lockfile that installs cleanly on that Mac. Vercel's builder is Linux. It installs from the committed lockfile. The Linux package is not in the lockfile, so it is not on disk, and Rollup throws the message above. The bug is in how the lockfile was written, not in your React code and not in the Vercel framework preset.
A related footgun is npm install --no-optional, or optional=false in an .npmrc that was committed. That setting skips optional dependencies on purpose. Rollup's native package is optional. The Linux build then fails the same way, even if the lockfile looks complete.
Regenerate the lockfile and commit it
- On a machine with a current npm, delete
node_modulesandpackage-lock.json. Do not deletepackage.json. - Run
npm installwith no--no-optionalflag. If.npmrcsetsoptional=falseoromit=optional, remove that line and install again. - Search the new lockfile for the Linux package. It should appear as a dependency of
rollup, not as something you added by hand:
node_modules/@rollup/rollup-linux-x64-gnuYou want that path inside package-lock.json. Seeing only @rollup/rollup-darwin-arm64 means the regenerate did not record Linux and the next Vercel build will fail the same way.
- Commit
package-lock.jsonand push. The file has to be in git. If it is gitignored, Vercel is not building the lockfile you just fixed. - In Vercel, redeploy and clear the build cache. A cached
node_modulesfrom the bad install can survive a normal redeploy and skip the corrected lockfile.
Do not add @rollup/rollup-linux-x64-gnu to dependencies or devDependencies to force the issue closed. Rollup maintainers treat these as optional platform packages. A direct dependency on the Linux build makes npm install fail on the Mac that generated the project. The lockfile entry is the fix that still lets each OS install its own binary.
If a fresh npm install still omits rollup-linux-x64-gnu, switch the project to pnpm. The Rollup issue thread is full of installs that failed under npm and succeeded under pnpm, because pnpm does not share this optional-dependency bug. That means deleting package-lock.json, adding pnpm-lock.yaml, and setting the Vercel install command to pnpm install. Do not leave both lockfiles. Vercel picks one, and an old npm lockfile will keep winning if it is still in the repo.
Confirm the Linux package is what the build used
- The build log should get past
vite buildwithoutrequireWithFriendlyError. - Locally,
grep rollup-linux-x64-gnu package-lock.json(or the pnpm lockfile) should print at least one hit. Commit that hit. - The deployment URL should serve the app. This error stops the build, so a Ready deployment means this particular failure is gone. A white screen after a green build is a different problem, usually
VITE_variables or the output directory. - If the log names
@rollup/rollup-linux-x64-muslinstead, you are not on Vercel's default image, or something in the build is Alpine. Match the package name in the error. For the error in the title of this guide, the gnu package is the one that has to be in the lockfile.
The same lockfile bug shows up on Cloudflare Pages, Netlify, and GitHub Actions whenever those runners are Linux and the lockfile came from macOS. The repair is the same: a lockfile that lists the Linux optional package, committed, with optional dependencies still enabled.
Questions that come up next
Why does npm install work on my Mac and fail on Vercel?
Rollup 4 ships a separate optional package for each operating system and CPU. The error text points at an npm bug, npm/cli issue 4828, that can omit optional dependencies for other platforms from the lockfile. A lockfile written on macOS can install the Darwin package locally and never record @rollup/rollup-linux-x64-gnu. Vercel installs from that lockfile on Linux, so the module is missing.
Should I add @rollup/rollup-linux-x64-gnu to dependencies?
No. Rollup already declares these packages as optional dependencies, selected by os and cpu. Putting one platform package in dependencies forces it onto every install. Mac and Windows installs then fail instead. Fix the lockfile so the optional package is recorded, and do not install with --no-optional.
Do I need the musl build instead of gnu?
Not for Vercel. The error names @rollup/rollup-linux-x64-gnu because Vercel's Node build image uses glibc. The musl package targets Alpine. Installing the musl package would not satisfy the import Rollup is making.