npm install fails with EACCES permission denied on Linux
Debian box, Node from the distro package, normal user. I want a small static server for testing and run:
Cite
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.$ 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_modulesWhat is the clean way to do global installs as a normal user? I would rather not change system directories at all. Terminal answers preferred.
Write something first.
Give people something to work with: at least 30 words on what happened and what you tried.
That is too long. Keep it under 6,000 characters.
Write the question as the title, 15 to 140 characters, no links.
Pick a category.
Add a name (2 to 40 characters, no links).
That email address does not look right.
That was quick. Read the thread, then try again.
The form expired. Reload the page and post again.
Something went wrong with the form. Reload and try again.
Please complete the check and post again.
Limit reached for now. Try again later.
This thread is closed to new replies.
This thread no longer accepts replies.
Something went wrong with the form. Reload and try again.
Post a reply or question first (name and email), then this browser can vote, edit and accept answers.
You cannot vote on your own post.
Only the author (within 30 days) or the forum team can do that.
That email already has an account. Use your sign-in link instead.
New accounts are paused for the moment. Try again later.
That was already posted.