Installing with Node Version Manager (nvm)
Node Version Manager (nvm) simplifies the management of multiple Node.js versions.
Install the nvm using the install script:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
Then install the latest Node.js version:
$ nvm install node
You can also install a specific Node.js version, by passing the major, minor, and/or patch versions:
$ nvm install 6
$ nvm install 4.2
You can then switch versions by passing the version the same way you do when installing:
$ nvm use 5
You can set a specific version of Node.js that you installed to be the default version by entering:
$ nvm alias default 4.2
To display a list of Node.js versions that are installed on your machine, enter:
$ nvm ls
When node is installed via nvm we don't have to use sudo
to install global packages since they are installed in home folder.
Thus npm i -g http-server
works.
Installing Node.JS in Windows
Node.JS can work as portable version (no need to install), or using an installer.
The portable version contain only one files: node.exe
that you can download from here:
https://nodejs.org/en/download/ It name: Windows Binary
.
The MSI installer also can be download from here:
Install Node.js From Source on Ubuntu
Prerequisites
sudo apt-get install build-essential
sudo apt-get install python
[optional]
sudo apt-get install git
Get source and build
cd ~
git clone https://github.com/nodejs/node.git
OR For node version 6.3.0
cd ~
wget https://nodejs.org/dist/v6.3.0/node-v6.3.0.tar.gz
tar xzvf node-v6.3.0.tar.gz
Change to the source directory such as in cd ~/node-v6.3.0
./configure
make
sudo make install
Install Node.JS via Version Manager
A better way to install node is to use a version manager such as NVM, because it allows you to quickly switch between different versions of Node quickly.
OSX:
- You'll need to install the Command Line Tools beforehand.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
Windows:
- Download the executable of nvm-windows from here
Installing Node.js on Mac using Homebrew
You can install Node.js using the Homebrew package manager.
Start by updating brew.
brew update
You may need to change permissions or paths. It's best to run this before proceeding:
brew doctor
Next you can install Node.js by running:
brew install node
Once Node.js is installed, you can validate the version installed by running:
node -v
Installing using MacOS X Installer
- Download the installer from Node.js official site.
- Upon completion of download, open the package and follow on-screen instructions
- Re-initialize your terminals (if they're already open)
You should now be able to use node
command from your terminals.