Use n
to manage your Node.js versions
Installation
- Install n through
npm
:(Recommended)
npm install -g n
Configurations
Since n
‘s default path is /usr/local/n
, it will need super user’s permission to modify file systems in the default path, we need to config n
‘s path to user’s path.
config N_PREFIX
- edit bash profile
vim ~/.bashrc
- add line
export N_PREFIX=~/.n
- apply file
source ~/.bashrc
config PATH
- edit bash profile
vim ~/.bashrc
- add a line
export PATH=$HOME/.n/bin:$PATH
- apply file
source ~/.bashrc
Use
# Use or install a version of node
n 9.0.0
# Use or install the latest official release
n latest
# Use or install the stable official release
n stable
# Use or install the latest LTS official release
n lts
Type n
to show list of versions.
And select a version by up down button.
$ n
node/8.9.3
node/9.0.0
node/9.2.1
ο node/9.3.0