# npm EACCES: permission denied, mkdir '/usr/local/lib/node_modules'

> A global install (`npm install -g @openai/codex`, for example) tried to write into a system folder owned by root. The exact message, why npm prints it, and the fix.

_Updated November 23, 2026_

## The message

```text
npm error code EACCES
npm error syscall mkdir
npm error path /usr/local/lib/node_modules
npm error Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'
```

## What it means

A global install (`npm install -g @openai/codex`, for example) tried to write into a system folder owned by root.

## Fix

1. Do not reach for sudo. Point npm at a folder you own: `npm config set prefix ~/.npm-global`, then add `~/.npm-global/bin` to your PATH.
2. Or install Node through a version manager (mise, nvm, fnm), whose global folder is yours.
3. For Claude Code, the native installer (`curl -fsSL https://claude.ai/install.sh | bash`) avoids npm altogether.

## In an EnvHaven workspace

No for the agents, whose support is built in. Global installs of your own go to a user-owned Node managed by mise.

## Where this comes from

This message was produced by npm itself, in a throwaway EnvHaven 1.9.0 container, on 2026-11-23; the text above is copied from that output.

## Keep reading

- [Every agent error](https://envhaven.com/errors)

Source: https://envhaven.com/errors/npm/eacces-permission-denied-mkdir-node-modules
