rollup native module 📦 npm

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

Rollup’s (and Vite’s) platform-specific optional dependency wasn’t installed — an npm optional-dependency bug with lockfiles from another platform.

Seen on: npm

Meaning

Lockfiles created on macOS may omit Linux optional packages. Deleting the lockfile and node_modules and reinstalling fixes it.

Common causes

  • Lockfile generated on another OS
  • npm bug with optional dependencies (npm/cli#4828)

⚡ Quick fix

  1. Delete node_modules and package-lock.json, then npm install
  2. Or install the missing package explicitly for CI

Detailed fix by platform

npm

  1. rm -rf node_modules package-lock.json && npm install

How to diagnose

  1. Lockfile — Generated on which OS?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.