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

Dung Do Tien Sep 26 2021 5

Hello guys. I am beginner in Nodejs. I have create a small project with Node and when I run and get an exception throw Error: EACCES: permission denied, access '/usr/local/lib/node_modules'.

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' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/macbookmd101/.npm/_logs/2021-09-21T16_26_08_421Z-debug.log

I am using node version 12.18.3. and OS Linux Ubuntu 18.04

Thanks for any suggestions.

Have 3 answer(s) found.
  • N

    Nguyen Quang Thai Sep 26 2021

    I think your account is not root account so you not have permission to access.

    You can change change owner permision, you can run command:

    sudo chown -R [owner]:[owner] /usr/local/lib/node_modules

    Or

    sudo chown -R ownerName: /usr/local/lib/node_modules

    Or

    sudo chown -R $USER /usr/local/lib/node_modules

    I hope it solve error for you.

  • S

    SAJID AHMAD Sep 26 2021

    You can try run command below to help access to root account:

     sudo su

    It maybe request access your password.

  • b

    bhavana b Sep 26 2021

    You need allow access to some folder as below:

    sudo chown -R $USER /usr/local/lib/node_modules/
    sudo chown -R $USER /usr/local/bin/
    sudo chown -R $USER /usr/local/share/

    Allow access only to node_modules folder might be your issue not be solved.

    I hope this answer useful for you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close