# Fix: `Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies` in CI

https://blog.cynexia.com/fix-error-cannot-find-module-rollup-rollup-linux-x64-gnu-npm-has-a-bug-related-to-optional-dependencies-in-ci

Author: [Rob Aleck](https://blog.cynexia.com/pages/about) · https://github.com/mnbf9rca · https://www.linkedin.com/in/robertaleck/ · https://family-foqos.app/

Published: 2025-09-04
Categories: Fix


Although builds were succeeding locally, during CI builds were failing on Linux with the error `Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies`. The log suggested removing `package-lock.json` - but this obviously breaks deterministic builds.

The root cause is a missing dependency - specifically, when Rollup needs native binaries for performance optimisation. Mac-generated lockfiles won't include Linux-specific optional dependencies. First noted in [npm bug 4828](<https://github.com/npm/cli/issues/4828>), it was fixed in npm 11.3.0+, but adding an explicit optional dependency prevents edge cases.

The fix is:

- add `@rollup/rollup-linux-x64-gnu: "*"` to `optionalDependencies` in `package.json`
- Update `package-lock.json` to include the platform-specific dependency

This allows builds to work reliably across platforms.

