How to fix npm throwing error without sudo
Full error message
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 0Solutionsource: stackoverflow \u2197
Watch OUT!!! Watch OUT!!! Watch OUT!!! chown or chmod is NOT the solution, because of security-risk. Instead do this, do: First check, where npm point to, if you call: npm config get prefix If /usr is returned, you can do the following: mkdir ~/.npm-global export NPM_CONFIG_PREFIX=~/.npm-global export PATH=$PATH:~/.npm-global/bin This create a npm-Directory in your Home-Directory and point npm to it. To got this changes permanent, you have to add the export-command to your .bashrc: echo -e "export NPM_CONFIG_PREFIX=~/.npm-global\nexport PATH=\$PATH:~/.npm-global/bin" >> ~/.bashrc
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/200dc8ab2fa86ecbe051c5afa61dc0715a1cf0c967049089a00cc1e6623a8cfchash \u00b7 200dc8ab2fa86ecbe051c5afa61dc0715a1cf0c967049089a00cc1e6623a8cfc