Installing Node.js All Versions
This draft deletes the entire topic.
Examples
-
Node Version Manager, otherwise known as nvm, is a bash script that simplifies the management of multiple Node.js versions.
To install nvm, use the provided install script:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
Then install the latest Node version:
$ nvm install node
You can also install a specific Node version, by passing the major, minor, and/or patch versions:
$ nvm install 6 $ nvm install 4.2
To list the versions available for install:
$ nvm ls-remote
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 that you installed to be the default version by entering:
$ nvm alias default 4.2
To display a list of Node 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. Thusnpm i -g http-server
works without any permission errors. -
All Node.js binaries, installers, and source files can be downloaded here.
You can download just the
node.exe
runtime or use the Windows installer (.msi
), which will also installnpm
, the recommended package manager for Node.js, and configure paths. -
-
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
-
Using the apt package manager.
sudo apt-get update sudo apt-get install nodejs sudo apt-get install npm sudo ln -s /usr/bin/nodejs /usr/bin/node # the node & npm versions in apt are outdated. This is how you can update them: sudo npm install -g npm sudo npm install -g n sudo n stable # (or lts, or a specific version)
-
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
-
All actions from super user (su).
Prerequisites
su cd curl http://linuxsoft.cern.ch/cern/scl/slc6-scl.repo > /etc/yum.repos.d/slc6-scl.repo rpm --import http://ftp.mirrorservice.org/sites/ftp.scientificlinux.org/linux/scientific/51/i386/RPM-GPG-KEYs/RPM-GPG-KEY-cern yum install -y devtoolset-3
...maybe one more
yum install -y krb5-devel
Get source and build
scl enable devtoolset-3 bash wget -qO ~/node.js.tar.gz https://nodejs.org/dist/v6.3.1/node-v6.3.1.tar.gz tar xf ~/node.js.tar.gz && cd ~/node-v6.* ./configure make -jX && make install
X - the number of processor cores, greatly speeds up the build
... and you can remove excess
cd rm -rf ~/node{-v6.*,.js.tar.gz}
-
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
-
To install v6.x update the packages
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
Using the apt package manager
sudo apt-get install -y nodejs
-
First, there is a really nice wrapper for setting up
n
on your system. Just run:curl -L https://git.io/n-install | bash
to install
n
. Then install binaries in a variety of ways:latest
n latest
stable
n stable
lts
n lts
Any other version
n <version>
e.g.
n 4.4.7
If this version is already installed, this command will activate that version.
Switching versions
n
by itself will produce a selection list of installed binaries. Use up and down to find the one you want and Enter to activate it. -
- 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. -
Node Version Manager (
nvm
) greatly simplifies the management of Node.js versions, their installation, and removes the need forsudo
when dealing with packages (e.g.npm install ...
). Fish Shell (fish
) "is a smart and user-friendly command line shell for OS X, Linux, and the rest of the family" that is a popular alternative among programmers to common shells such asbash
. Lastly, Oh My Fish (omf
) allows for customizing and installing packages within Fish shell.This guide assumes you are already using Fish as your shell.
Install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
Install Oh My Fish
curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish
(Note: You will be prompted to restart your terminal at this point. Go ahead and do so now.)
Install plugin-nvm for Oh My Fish
We will install plugin-nvm via Oh My Fish to expose
nvm
capabilities within the Fish shell:omf install nvm
Install Node.js with Node Version Manager
You are now ready to use
nvm
. You may install and use the version of Node.js of your liking. Some examples:- Install the most recent Node version:
nvm install node
- Install 6.3.1 specifically:
nvm install 6.3.1
- List installed verisons:
nvm ls
- Switch to a previously installed 4.3.1:
nvm use 4.3.1
Final Notes
Remember again, that we no longer need
sudo
when dealing with Node.js using this method! Node versions, packages, and so on are installed in your home directory. - Install the most recent Node version:
Topic Outline
- Using Node Version Manager (nvm)
- Installing Node.js on Windows
- Installing Node.js on Mac using Homebrew
- Install Node.js on Ubuntu
- Install Node.js From Source on Ubuntu
- Install Node.js v 6.x from source on Centos 6.x x64
- Install Node.JS via Version Manager
- Installing Node.js on Raspberry PI
- Installing Node.js with n
- Installing using MacOS X Installer
- Installing with Node Version Manager under Fish Shell with Oh My Fish!
Sign up or log in
Save edit as a guest
Join Stack Overflow
Using Google
Using Facebook
Using Email and Password
We recognize you from another Stack Exchange Network site!
Join and Save Draft