npm -g do no install with sudo

NPM by default is really dumb and has it's default prefix to /usr/local (or /usr). This is the best configuration to mess up with your distribution package manager. (But Javascript guys seem to not be concerned by distribution constraints everything…)

You can check with :

npm conf get prefix

To change this, create a directory in your home to receive npm package.

For example :

mkdir ~/.npm_user_pkg

Change NPM prefix to :

npm config set prefix '~/.npm_user_pkg/'

And add this to your ~/.profile to change your $PATH env variable :

export PATH="${HOME}/.npm_user_pkg/bin:$PATH"

And now, you can install npm package globaly (with -g) without sudo, for your $USER.

For example :

npm install -g eslint

Add a comment

Comments can be formatted using a simple wiki syntax.

Add ping

Trackback URL : https://blog.beneth.fr/trackback/53

Page top