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)
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - apt-get install -y nodejs
Also, for the right way to install global npm modules, set the personal directory for them (eliminates the need for sudo and avoids EACCES errors):
mkdir ~/.npm-global echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.profile source ~/.profile npm config set prefix '~/.npm-global'
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 install
npm, the recommended package manager for Node.js, and configure paths.
Installation by package manager
You can also install by package manager Chocolatey (Software Management Automation).
# choco install nodejs.install
More information about current version, you can find in the choco repository here.
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
For windows there is a nvm-windows package with an installer. This GithHub page has the details for installing and using the nvm-windows package.
After installing nvm, run "nvm on" from command line. This enables nvm to control the node versions.
Note: You may need to restart your terminal for it to recognize the newly installed
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
To use project-specific node versions, you can save the version in .nvmrc file. This way, starting to work with another project will be less error-prone after fetching it from its repository.
$ echo "4.2" > .nvmrc $ nvm use Found '/path/to/project/.nvmrc' with version <4.2> Now using node v4.2 (npm v3.7.3)
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 without any permission errors.
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 the latest LTS Node.js version 6.10.2
cd ~ wget https://nodejs.org/dist/v6.3.0/node-v6.10.2.tar.gz tar -xzvf node-v6.10.2.tar.gz
Change to the source directory such as in
./configure make sudo make install
You can install Node.js using the Homebrew package manager.
Start by updating brew:
You may need to change permissions or paths. It's best to run this before proceeding:
Next you can install Node.js by running:
brew install node
Once Node.js is installed, you can validate the version installed by running:
You can also install node.js through Macports.
First update it to make sure the lastest packages are referenced:
sudo port selfupdate
Then install nodejs and npm
sudo port install nodejs npm
You can now run node through CLI directly by invoking
node. Also, you can check your current node version with
You can find the installers on Node.js download page. Normally, Node.js recommends two versions of Node, the LTS version (long term support) and the current version (latest release). If you are new to Node, just go for the LTS and then click the
Macintosh Installer button to download the package.
If you want to find other NodeJS releases, go here, choose your release then click download. From the download page, look for a file with extension
Once you downloaded the file (with extension
.pkg ofcourse), double click it to install. The installer packed with
npm, by default, the package will install both but you can customize which one to install by clicking the
customize button in the
Installation Type step. Other than that, just follow the installation instructions, it's pretty straightforward.
terminal (if you don't know how to open your terminal, look at this wikihow). In the terminal type
node --version then enter. Your terminal will look like this if Node is installed:
$ node --version v7.2.1
v7.2.1 is your Node.js version, if you receive the message
command not found: node instead of that, then it's mean there is a problem with your installation.
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
Node Version Manager (
nvm) greatly simplifies the management of Node.js versions, their installation, and removes the need for
sudo 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 as
bash. 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.
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:
nvm install node
nvm install 6.3.1
nvm use 4.3.1
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.
Node.js v6.x LTS
git clone -b v6.x https://github.com/nodejs/node.git
git clone -b v7.x https://github.com/nodejs/node.git
cd node ./configure make -jX su -c make install
X - the number of processor cores, greatly speeds up the build
cd rm -rf node
First, there is a really nice wrapper for setting up
n on your system. Just run:
curl -L https://git.io/n-install | bash
n. Then install binaries in a variety of ways:
Any other version
If this version is already installed, this command will activate that version.
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.