EROFS 📦 npm

npm ERR! code EROFS — EROFS: read-only file system

npm tried to write to a read-only location (read-only container filesystem, mounted volume, or system path).

Seen on: npm

Meaning

Containers with readOnlyRootFilesystem, serverless environments (/var/task is read-only) and global installs into system paths cause it.

Common causes

  • Read-only container root filesystem
  • Serverless runtime directories
  • Writing cache to a read-only HOME

⚡ Quick fix

  1. Install at build time, not at runtime
  2. Point the npm cache to /tmp (npm_config_cache=/tmp/.npm)
  3. Mount a writable volume

Detailed fix by platform

npm

  1. npm_config_cache=/tmp/.npm npm ci

How to diagnose

  1. Path — Which path is read-only?
  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.