Skip to content
Nilay Kabariya

Entry No.110·Fixes··3 min read

Cannot find module @rollup/rollup-linux-x64-gnu: what causes it

Rollup blames an npm bug and says to delete your lockfile. On npm 11 that wasn't it: five setups that gave the error on Linux and Alpine, and the fix for each.

by Nilay#node#npm#docker#linuxFIXED

The error, verbatim

Jump to the fix ↓
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.
    at requireWithFriendlyError (/home/runner/work/_temp/work/c/node_modules/rollup/dist/native.js:126:9)
✓ Reproduced on GitHub Actions windows-latest, macos-latest and ubuntu-latest, plus node:24-alpine in Docker, November 22,

The fix that worked

Reinstall on the machine that runs the build; the lockfile can stay:

rm -rf node_modules
npm ci
Not it? Every cause, tested ↓

Tested on

Rollup
4.68.8 (the current latest)
Node / npm
24.22.3 / 11.19.1
OS
GitHub Actions windows-latest, macos-latest and ubuntu-latest, plus node:24-alpine in Docker, November 22, 2026

Rollup 4 runs its parser from a native package for each platform: @rollup/rollup-linux-x64-gnu, @rollup/rollup-darwin-arm64, @rollup/rollup-win32-x64-msvc and so on. They are optional dependencies of rollup, and npm installs only the ones whose OS and CPU match the machine (on Windows x64 that was two, win32-x64-gnu and win32-x64-msvc). When Rollup can’t load the one for the machine it is running on, it throws this error. Vite 5 to 7 build with Rollup 4, so their builds show the same message.

The message blames an npm bug (npm/cli#4828) and says to delete package-lock.json. I tested that first: with npm 11.19.1, a lockfile made on Windows, on macOS or on Linux each listed all 26 Rollup platform packages, and npm ci on Linux installed the Linux one and built. The causes I could reproduce were all about which node_modules the build runs with.

Which cause is yours

What happened Missing package What fixed it
node_modules from a Windows or macOS machine used on Linux (copied, cached or committed) rollup-linux-x64-gnu npm ci on Linux; the lockfile kept
npm ci --omit=optional rollup-linux-x64-gnu plain npm ci
omit=optional in .npmrc rollup-linux-x64-gnu npm ci --include=optional
the platform folder deleted from node_modules rollup-linux-x64-gnu npm i, with the lockfile kept
node_modules installed on Ubuntu, run in an Alpine container rollup-linux-x64-musl install inside the container (anonymous volume for node_modules)

The package named in the message tells you which machine is running the build: linux-x64-gnu is a normal Linux, linux-x64-musl is Alpine. If that doesn’t match where node_modules was installed, that’s the cause.

node_modules from another machine

This is a common cause in CI and Docker reports: node_modules installed on a laptop reaches a Linux build, through a COPY . . without a .dockerignore, a cache restored from another OS, or a committed folder. It holds the laptop’s platform package and not Linux’s.

Install on the machine that builds, from the lockfile:

rm -rf node_modules
npm ci

In Docker, keep node_modules out of the build context (add it to .dockerignore) and run npm ci in the Dockerfile.

The .dockerignore and Dockerfile advice is what this result points to; no Dockerfile build was run.

Optional dependencies turned off

--omit=optional, or omit=optional in .npmrc, skips every platform package. npm ci exited 0 and added 2 packages instead of 3 (in the --omit=optional run, node_modules/@rollup didn’t exist), and the build failed.

Remove the omit=optional line or flag, or override it for this install:

npm ci --include=optional

Alpine: the musl package

Alpine uses musl, not glibc, so Rollup asks for @rollup/rollup-linux-x64-musl there. A node_modules installed on an Ubuntu host and mounted into a node:24-alpine container holds only the glibc package:

Error: Cannot find module @rollup/rollup-linux-x64-musl. npm has a bug related to optional dependencies ...

npm ci inside the container, with the same lockfile from Ubuntu, installed rollup-linux-x64-musl and built. With a bind mount of the project, add an anonymous volume so the container keeps its own node_modules:

docker run --rm -v "$PWD":/app -v /app/node_modules -w /app node:24-alpine sh -c "npm ci && npm run build"

Deleting the lockfile: works, but wasn’t needed

The message’s own advice, rm -rf node_modules package-lock.json && npm i, fixed the deleted-folder case. So did plain npm i with the lockfile and the rest of node_modules kept, and npm ci fixed the other cases with the lockfile kept. Deleting the lockfile also lets npm re-resolve every dependency within its version range, which can pull in newer versions, which is a bigger change than this error needs.

npm 11’s lockfile listed every platform package no matter which OS made it. Lockfiles written by older npm versions were not tested; if yours lacks a node_modules/@rollup/rollup-linux-x64-gnu entry, that’s the bug the message refers to, and regenerating the lockfile is the fix.

For the Vite 8 version of this problem, where the missing package is @rolldown/binding-*, see Cannot find native binding in Vite 8.

How this was tested

GitHub Actions, November 22, 2026, Node 24.22.3, npm 11.19.1, Rollup 4.68.8. A minimal project (rollup as a devDependency, "build": "rollup main.js --file out.js") was installed and built on windows-latest, macos-latest (arm64) and ubuntu-latest; each lockfile and a tarball of each node_modules went to a second job on ubuntu-latest (glibc 2.43), which ran every case there and in node:24-alpine. Linux arm64, Yarn, pnpm and Bun were not tested, nor was a Vite build itself. The workflow, the scripts and the output are in nk-repro/rollup-native-binding.

— N.K., end of entry No.110

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.108

    sh: vite: command not found on Linux, macOS, CI and Docker

    sh: vite: command not found in CI, Docker or a Linux shell: six causes tested on Ubuntu and macOS, the exact message each one prints, and which fix worked.

    > > vite build

    FIXED4 min
  2. No.093

    Fix: bigint Failed to load bindings, pure JS will be used

    bigint: Failed to load bindings, pure JS will be used. Why npm 12 shows it on every install, whether it matters, and how to get the native build back.

    > bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

    FIXED3 minWindows
  3. No.090

    Node 26 error: libatomic.so.1 cannot open shared object file

    node: error while loading shared libraries: libatomic.so.1 after moving to Node 26? Tested on 9 Linux images, Docker and nvm: what each distro is missing.

    > node: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory

    FIXED4 min

tip: paste the exact error text