#6631: fix: configure npm global prefix for non-root user in Docker
docker
Cluster:
Docker Configuration Improvements
## Problem
The Dockerfile switches to the non-root `node` user for security hardening, but npm's default global prefix (`/usr/local`) is not writable by this user. This causes `EACCES: permission denied` errors when installing skills via ClawdHub or any `npm install -g` command.
```
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/clawdhub'
```
## Fix
Add two lines after `USER node` to configure npm to use a user-writable directory:
```dockerfile
RUN npm config set prefix /home/node/.npm-global
ENV PATH="/home/node/.npm-global/bin:${PATH}"
```
This is the standard Node.js recommended fix for [resolving EACCES permissions errors](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
## Scope
Dockerfile only — 2 lines added. No other changes.
Fixes #6620
Related: #4130
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the runtime Docker image to support global npm installs while running as the non-root `node` user. After switching to `USER node`, it creates a user-writable global prefix directory under `/home/node/.npm-global`, sets npm’s global prefix to that path, and adds the corresponding `bin` directory to `PATH`, preventing `EACCES` errors for `npm install -g` (e.g., when installing skills via ClawHub).
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is isolated to the Dockerfile and follows standard npm guidance; it creates the prefix directory before setting it and only affects runtime global install behavior for the non-root `node` user.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#5458: fix: set correct file ownership in Dockerfile (#5450)
by hakyonglee · 2026-01-31
82.5%
#11333: fix(docker): align host directory ownership with container user
by liuxiaopai-ai · 2026-02-07
81.8%
#7938: fix(agents): install node skills with --prefix CONFIG_DIR for non-r...
by logozorro · 2026-02-03
80.2%
#11818: fix(docker): resolve build hang by using in-place ownership and opt...
by dilly · 2026-02-08
79.9%
#17151: fix: add npm link to fix CLI permission denied (exit 127)
by sskyu · 2026-02-15
79.5%
#3513: fix(docker): add MOLTBOT_STATE_DIR to resolve permission error
by Suksham-sharma · 2026-01-28
78.9%
#23079: fix(skills): fallback to npm for summarize skill on non-darwin systems
by charojo · 2026-02-22
77.4%
#13737: Docker: harden UID/GID remap and docker-setup flow, convenience upd...
by ramarnat · 2026-02-10
77.1%
#8376: Docker: inline chown to reduce image size and build time
by bugparty · 2026-02-03
76.2%
#3324: Update Dockerfile to support Homebrew and Go for skill execution
by nnnet · 2026-01-28
76.2%