I just installed node and npm through the package on nodejs.org and whenever I try to search or install something with npm it throws the following error, unless I sudo the command. I have a feeling this is a permissions issue? I am already the admin.
npm ERR! Error: EACCES, open '/Users/chietala/.npm/-/all/.cache.json'
npm ERR! { [Error: EACCES, open '/Users/chietala/.npm/-/all/.cache.json']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/chietala/.npm/-/all/.cache.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.2.0
npm ERR! command "node" "/usr/local/bin/npm" "search" "bower"
npm ERR! cwd /Users/chietala
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! path /Users/chietala/.npm/-/all/.cache.json
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Users/chietala/.npm/-/all/.cache.json'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/chietala/npm-debug.log
npm ERR! not ok code 0
This looks like a permissions issue in your home directory. To reclaim ownership of the .npm directory execute:
sudo chown -R $(whoami) ~/.npm
I thought that
whoami
was a placeholder, but it works typed literally as-is, so it must be a variable I don't understand.whoami is an actual shell command en.wikipedia.org/wiki/Whoami. The backticks around
whoami
ensure that it gets executed correctly and then placed into the chown commandyou could manually specify your username as well. If your username is "simpleascouldbe", the command would be
sudo chown -R simpleascouldbe ~/.npm
npm does NOT require nor should you be using sudo - see answer below @HeberLZ in particular his 2nd option regarding : ./configure --prefix=xxxxxx
@ChristopherWill: This is not changing the ownership of a system directory. This is changing the ownership of directories in the user's home directory, which should be owned by the user.