# npm install fails with EACCES permission denied on Linux

Source: https://coursesweb.net/forum/t/npm-install-fails-with-eacces-permission-denied-on-linux/
Site: CoursesWeb Forum, category Node.js and Server Side JavaScript
Published: 2026-12-04. Updated: 2026-12-04. Replies: 2.

## Question by Bertie H., 2026-12-04

Debian box, Node from the distro package, normal user. I want a small static server for testing and run:

```
$ npm install -g http-server
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/lib/node_modules/http-server
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/http-server'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/http-server'] {
```

Obviously /usr/lib belongs to root. I can sudo it, but I have been burned by root owned files in my home directory before, and I do not like the idea of npm running install scripts as root.

```
$ node -v
v18.19.0
$ npm -v
9.2.0
$ ls -ld /usr/lib/node_modules
drwxr-xr-x 3 root root 4096 Oct 14 09:12 /usr/lib/node_modules
```

What is the clean way to do global installs as a normal user? I would rather not change system directories at all. Terminal answers preferred.

## Reply 1 by Zaid M., 2026-12-04

had this on my school pc. sudo chmod -R 777 /usr/lib/node_modules fixed it for me, then npm install works without sudo. i dont know what 777 means exactly but the error went away and the install finished

## Reply 2 by Mpho N., 2026-12-04

Just use sudo npm install -g http-server. It is a global tool, so it makes sense that it goes into a root folder. Lecturers do this all the time. On my laptop with Ubuntu I always put sudo in front and never had a problem with the install itself.

---
Cite as: CoursesWeb Forum, "npm install fails with EACCES permission denied on Linux", https://coursesweb.net/forum/t/npm-install-fails-with-eacces-permission-denied-on-linux/, accessed 2026-12-05.
