1. Download & Install LTS NodeJS Package from [here](https://nodejs.org/en/)
2. Create new Directory for NPM and Global Packages:
`mkdir ~/.npm-packages`
3. Configure NPM to use the new directory:
`npm config set prefix ~/.npm-packages/`
4. Create or Modify `~/.bash_profile` or `~/.zshrc` and add the following:
**NOTE:** Starting with macOS Catalina, ZSH will be the default shell
**NOTE:** I use [Visual Studio Code](https://code.visualstudio.com) and have enabled [Launching from the command line](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line).
`code ~/.bash_profile` or `code ~/.zshrc`
Add the following line to `~/.bash_profile` or `~/.zshrc`
```
# The next line is for running NPM
export PATH=~/.npm-packages/bin:$PATH
```
5. Run the below command to update system variables:
`source ~/.bash_profile` or `source ~/.zshrc`
**NOTE:** I highy recommend you completely exit and restart Terminal/SecureCRT instead of running this command to ensure configuration sticks.
6. Verify NPM is running in your new location:
`npm list -g -depth=0`
> Output should look similar to below (emphasis added):
```
JMCOMBSMBP:~ jmcombs$ npm list -g -depth=0
\!h /Users/jmcombs/.npm-packages/lib
└── npm@6.9.0
```
7. Upgrade NPM to the latest version
* `npm install npm -g`
8. Verify NPM is latest version (at the time of writing this it is **6.9.0**)
`npm list -g -depth=0`
> Output should look similar to below (emphasis added):
```
JMCOMBSMBP:~ jmcombs$ npm list -g -depth=0
/Users/jmcombs/.npm-packages/lib
└── npm@6.9.0
```
`npm -v`
> Output should look similar to below (emphasis added):
```
JMCOMBSMBP:~ jmcombs$ npm -v
\!h 6.9.0
```
9. Success
Sources used for this article:
- [Special formatting for snippet code](https://support.cacher.io/hc/en-us/articles/115003177772)
- [Resolving EACCES permissions errors when installing packages globally](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)
- [Node and npm without sudo](https://johnpapa.net/node-and-npm-without-sudo/)