« npm -g » do not install with sudo

NPM by default is really dumb and has its default prefix set to /usr/local (or /usr). This is the best configuration to mess up with your distribution package manager. You can check with :

npm conf get prefix

To change this, create a directory in your home to store 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 globally (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