ECMAScript Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. Open your command-line application.
  2. Clone the nvm project into a directory in your home folder:
git clone https://github.com/creationix/nvm.git ~/.nvm
  1. Add the following code to the bottom of your ~/.bashrc or ~/.zshrc file. If you don't know what shell you are running, it is probably bash and you should add the entry to ~/.bashrc:
# Configure NVM 
export NVM_DIR="$HOME/.nvm" 
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" 
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"   
  1. Save the file and return to your command line:
source ~/.bashrc # (or ~/.zshrc if you're running zshell)
  1. Confirm your installation by checking the version number of nvm:
> nvm --version
0.33.5
  1. List all of the node versions available for installation:
> nvm list-remote
  1. Install the latest Long Term Support (LTS) or stable version. (At the time of writing, version 8.9.4 is the latest LTS version):
    > nvm install 8.9.4
  1. Confirm the installation of node and npm by checking their version numbers:
    >  node --version
    v8.9.4
    > npm --version
5.6.0