How to fix EACCES problems with installing npm

Some of my node modules are installed, but there are always such problems on this particular Linux coin machine.

npm install npm ERR! Error: EACCES, open '/home/me/.npm/semver/3.0.1/package/package.json' npm ERR! { [Error: EACCES, open '/home/me/.npm/semver/3.0.1/package/package.json'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/home/me/.npm/semver/3.0.1/package/package.json', npm ERR! parent: 'gulp' } npm ERR! npm ERR! Please try running this command again as root/Administrator. 
+7
npm
Aug 13 '14 at 16:04
source share
2 answers

This code fix it for me.

 sudo chown -R `whoami` ~/.npm sudo chown -R `whoami` /usr/local/lib/node_modules 
+14
Dec 03 '14 at 6:42
source share

UPDATE See this answer for a better way.




You must set the correct permissions (ownership) so that npm can access your (under) directories with your normal user permissions:

 sudo chown -R $USER <directory> 

where in your case <directory> is /home/me and -R is for recursive, to also change ownership of all your subdirectories, which is exactly what you want. This should fix the EACCESS problem.

Unfortunately, the tip for running the root/Administrator command is wrong here.

You want to avoid running npm with sudo ever since recommended by the creator of npm Isaac Schlüter :

I highly recommend that you do not do package management with sudo! Arbitrary scripts can be executed in packages, which makes the package manager’s team safe, like cutting a chainsaw. Of course, he’s quickly and definitely going to overcome any obstacles, but you really may need an obstacle to stay there.

See here for more details .

+5
Apr 22 '15 at 4:45
source share



All Articles