debugModerate
EPERM and EACCES errors — file permission issues in Node.js
Viewed 0 times
EPERMEACCESpermission deniednpm globalfile permissionschmodDocker user
nodejsdockerlinuxmacosci-cd
Error Messages
Problem
Node.js file operations fail with EPERM (operation not permitted) or EACCES (permission denied). Common with npm global installs, Docker volumes, and CI/CD pipelines.
Solution
(1) npm global: never use sudo with npm. Fix with: mkdir ~/.npm-global, npm config set prefix '~/.npm-global', add to PATH. Or use nvm/fnm which handles this automatically. (2) Docker: match container user UID/GID with host user for bind mounts. (3) File locks: another process has the file open (EPERM on Windows). (4) Read-only file system in Docker: check volume mount options. (5) CI: ensure the runner user owns the workspace directory.
Why
Unix file permissions (owner/group/other) restrict access. Node.js runs as the current user and inherits their permissions. Docker containers run as root by default but host files retain their original permissions.
Revisions (0)
No revisions yet.