Change NPM Global Directory for Packages (fix permissions)

?
R
Bash

Recipe adapted from official NPM docs https://docs.npmjs.com/getting-started/fixing-npm-permissions

1# Create a folder for the packages and update npm config to become aware of it
2mkdir ~/.npm-global
3npm config set prefix '~/.npm-global'
4
5# Export to PATH (persist) via a .profile
6touch ~/.profile
7echo "export PATH=~/.npm-global/bin:$PATH" | cat ~/.profile -
8
9# Reads and execute the command to export in the current shell environment (so that you can use it straight away)
10source ~/.profile
11
12# Install something
13npm install -g loopback-cli

Created on 4/29/2018