Install NPM packages in home directory

Create the ~/.npmrc file with the following content:

prefix = "~/.local"

Add the following line to your .bash_profile:

export PATH=~/.local/bin:$PATH

Now you can install a npm package without your root password:

npm install -g eclint
# /home/me/.local/bin/eclint -> /home/me/.local/lib/node_modules/eclint/bin/eclint.js
# + eclint@2.8.1
# updated 1 package in 11.149s

which eclint
# /home/me/.local/bin/eclint