I don't know how I've managed it but npm seems to need sudo
for absolutely every command, even npm help
does not work without sudo. If I use a command without sudo
, I do not see am EACCESS
error, but instead my terminal session hangs and then just closes that tab (I use iTerm on Mac).
I have tried changing the ownership of my local .npm
folder, outlined here and also done the same on my /usr/local/bin
folder where node is installed but none of these allow me to just run npm without sudo
, even when installing local packages...! It seems to me that something has screwed along the way, can anyone help?
Many thanks
Take ember project for example, I give all related project directory root:
neil@neil-System-Product-Name:~/Projects/ember-quickstart$ sudo chown -R $(whoami) /home/neil/Projects/ember-quickstart/
neil@neil-System-Product-Name:~/Projects/ember-quickstart$ ember s Could not start watchman Visit https://ember-cli.com/user-guide/#watchman for more info. Livereload server on http://localhost:7020 Build successful (10679ms) – Serving on http://localhost:4200/ Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+--------------------- Babel (18) | 7561ms (420 ms)
Concat (8) | 1872ms (234 ms)
Rollup (1) | 629ms
I had this as well on my machine. What I did to fix it (there are probably much less extreme ways) was to completely remove npm, and then did a fresh installation node.js (with which npm is included) from http://nodejs.org/ making sure I didn't install as root. That then allowed me to use npm without root (except for global installs).
I encountered the same error after a fresh install of 0.12.4 today; this solved the problem for me:
In my particular case, I noticed that this folder was owned by '{some-large-integer-account}:wheel'...YMMV
If that doesn't solve it, take a look at the ownership of the folders that are being blocked as mentioned in the EACCESS error trace. If you're not sure what the ownership should be, you can usually infer it from the sibling dirs' ownership.