We are no longer accepting contributions to Documentation. Please see our post on meta.

Node.js

Installing Node.js All Versions

v0.1
v0.2
v0.3
v0.4
v0.5
v0.6
v0.7
v0.8
v0.9
v0.10
v0.11
io.js v1.0
io.js v1.1
io.js v1.2
io.js v1.3
io.js v1.4
io.js v1.5
io.js v1.6
io.js v1.7
io.js v1.8
io.js v2.0
io.js v2.1
io.js v2.2
io.js v2.3
io.js v2.4
io.js v2.5
io.js v3.0
io.js v3.1
io.js v3.2
io.js v3.3
v4.0
v4.1
v4.2
v5.0
v5.1
v5.2
v5.3
v5.4
v5.5
v0.12
v4.3
v5.6
v5.7
v4.4
v5.8
v5.9
v5.10
v5.10.1
v5.11.0
v6.0.0
v5.11.1
v6.1.0
v6.2.0
v6.2.1
v6.2.2
v5.12.0
v6.3.0
v6.3.1
v6.4.0
v6.5.0
v6.6.0
v6.7.0
v6.8.0
v6.8.1
v6.9.0
v6.9.1
v7.0.0
v7.1.0
v7.2.0
v6.9.2
v7.2.1
v7.3.0
v7.4.0
v6.9.3
v6.9.4
v6.9.5
v7.5.0
v6.10.0
v7.6.0
v7.7.0
v7.7.1
v7.7.2
v7.7.3
v6.10.1
v7.7.4
v7.8.0
v6.10.2
v7.9.0
v6.10.3
v7.10.0
v8.0.0
v6.11.0
v8.1.0
v8.1.1
v8.1.2
v8.1.3
v8.1.4
v8.2.0
v8.2.1

This draft deletes the entire topic.

Examples

  • 31

    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 nvm command.

    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.

  • 9

    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
    

    Macports

    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

    node -v
    
  • 8

    Standard installation

    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.

  • 5

    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)
    

    Using the latest of specific version (e.g. LTS 6.x) directly from nodesource

    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'
    
  • 2

    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.

  • 0

    Prerequisites

    • git
    • clang and clang++ 3.4^ or gcc and g++ 4.8^
    • Python 2.6 or 2.7
    • GNU Make 3.81^

    Get source

    Node.js v6.x LTS

    git clone -b v6.x https://github.com/nodejs/node.git
    

    Node.js v7.x

    git clone -b v7.x https://github.com/nodejs/node.git
    

    Build

    cd node
    ./configure
    make -jX
    su -c make install
    

    X - the number of processor cores, greatly speeds up the build

    Cleanup [Optional]

    cd 
    rm -rf node
    
  • 0

    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 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 cd ~/node-v6.10.2

    ./configure
    make
    sudo make install
    
  • 0

    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
    
  • 0

    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.

    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.

  • -1

    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 .pkg.

    Once you downloaded the file (with extension .pkg ofcourse), double click it to install. The installer packed with Node.js and 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.

    Check if Node is installed

    Open 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
    

    The 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.

Please consider making a request to improve this example.

Syntax

Syntax

Parameters

Parameters

Remarks

Remarks

Still have a question about Installing Node.js? Ask Question

Topic Outline


    We are no longer accepting contributions to Documentation. Drafts cannot be modified.