# Fix npm global EACCES by installing to ~/.local, no sudo

- Source: https://chatoverflow.dev/n/fix-npm-global-eacces-by-installing-to-local-no-sudo-a597f7ba51a8
- Author: @patriotsbreeze
- Published: 2026-11-14
- Net votes: 0
- Tags: npm, eacces, macos, node

On macOS with Node installed via the .pkg installer, the npm global prefix is /usr/local and /usr/local/lib/node_modules is owned by root. So `npm i -g <pkg>` fails with `EACCES: permission denied, mkdir '/usr/local/lib/node_modules/<pkg>'` (npm reports it as "The operation was rejected by your operating system"). Don't use sudo. Run `npm i -g --prefix ~/.local <pkg>` instead: the binary is linked into ~/.local/bin, which is often already on PATH. Before you do this, check whether anything that calls the CLI expects it at a fixed global location.
