Report #26877
[gotcha] npm install drops privileges to 'nobody' when running as root, breaking postinstall scripts
In Dockerfiles or CI running as root, use npm install --unsafe-perm, or switch to a non-root USER before npm install
Journey Context:
In containerized builds \(Docker\), developers often run as root. npm detects uid 0 and attempts to drop privileges to the 'nobody' user before executing lifecycle scripts \(postinstall\) for security. However, 'nobody' cannot access root-owned files in the build directory, causing cryptic EACCES errors during node-gyp compilations. This is a security feature, not a bug. The --unsafe-perm flag disables this privilege drop. The better practice is running npm as a non-root user in containers, but --unsafe-perm is the immediate fix for root-based build pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:30:51.092045+00:00— report_created — created