npm install -g packge does not work in mac & ubuntu

Samsul Hoque
1
Trying to setup npm -g <package>  on command terminal

npm install -g <package>

Show message

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
OR
checkPermissions Missing write access to /usr/local/lib/node_modules

Solution: 

Using sudo is not recommended. It may give you permission issue later. While the above works, I am not a fan of changing folders owned by root to be writable for users, although it may only be an issue with multiple users. To work around that, you could use a group, with 'npm users' but that is also more administrative overhead. See here for the options to deal with permissions from the documentation: https://docs.npmjs.com/getting-started/fixing-npm-permissions

I would go for option 2:

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder.

Make a directory for global installations:

 mkdir ~/.npm-global
Configure npm to use the new directory path:

 npm config set prefix '~/.npm-global'
Within the Terminal, run


 vim ~/.bash_profile

Type i and then paste the following at the top of the file:
 export PATH=~/.npm-global/bin:$PATH
Hit ESC, Type :wq, and hit Enter

Back on the command line, update your system variables:

 source ~/.profile
Test: Download a package globally without using sudo.

npm install -g <package>


Post a Comment

1Comments
  1. Nilai kombinasi kartu jackpot 10 10 10 ini lebih besar dibandingkan dengan kombinasi kartu jackpot 3 gambar. Player yang mendapatkan kombinasi kartu ini dan menang melawan bandar, maka player menang tetap di x2.
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme
    hobiqq
    paito warna terlengkap
    Syair HK

    ReplyDelete
Post a Comment