• Register
0 votes

Problem :

I am new to npm and now I am facing strange looking below error 

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'”

Detailed error as below:

npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }

Have somebody fixed this before?

2.3k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had also faced such issues. I think currently you are facing permission issues. I think you are trying to install the npm-packages and getting the EACCES error while trying to install the package globally. The error is suggesting that you do not have the required permission to write to required directories which npm uses to store the global packages and commands.

To cross check try to run below commands: 

sudo chmod u+x -R 775 ~/.npm 

sudo chown $USER -R ~/.npm 

If you want to install the npm-package locally then in that case you should be in the local project directory and then you can try running below command

sudo npm install <pkg-name> 

The above command will install the required package. Now the purpose of using the sudo is to change the owner permissions so that you can make the current user authorized to run the npm commands.

5k points