-
Notifications
You must be signed in to change notification settings - Fork 2
Install Node.js
tags: Node.js
[TOC]
in mac os, you could use nvm manage different node.js version
nvm is node.js version manager
To install or update nvm, you can use the install script using cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
notice that install.sh could use lastet version in github
The script clones the nvm repository to /.nvm and adds the source line to your profile (/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm install stable
nvm install v6.9.5
nvm list #show local install versions
nvm use 6.9.5 #just modify current tab bash $PATH , if you open other tab bash node version is default version
nvm current ## set current node use version
node -v
nvm --help #learn from help or readme.md
first, use npm install module (npm like python pip)
mkdir -p ~/Development/lesson1
npm init #to create package.json
npm install module_name --save #add module_name to package.json
use nvm-windows manage node.js version
offical install reference
1.download noinstall version
2.extract to C:\nvm-noinstall, execute intsall.cmd to set some variable

3.set PATH
"%PATH%;%NVM_HOME%;%NVM_SYMLINK%"
4.cp -f C:\settings.txt C:\nvm-noinstall\settings.txt
5.config

6.test
nvm -verion //test if nvm install
nvm install v6.9.5 //install v6.9.5 in NVM_HOME
nvm use 6.9.5 //NVM_SYMLINK to v6.9.5 install PATH
git clone https://github.com/cnpm/nvm.git ~/.nvm && cd ~/.nvm && git checkout git describe --abbrev=0 --tags
add this line to ~/.bash_profile and source it . ~/.nvm/nvm.sh
use mirror
append to .bash_profile, and source .bash_profile, also you can using .bashrc file as well
NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node