How to install latest node version on Ubuntu?

12,816

Solution 1

This is very simple, Grab the Linux node distribution from here: https://nodejs.org/dist/v6.2.0/

Open Terminal and type below command:

sudo tar -C /usr/local --strip-components 1 -xzf ~/Downloads/node-v6.2.0-linux-x64.tar.gz

ls -l /usr/local/bin/node

That`s it.

Now check your node version by typing:

node -v
npm -v

One can install any version of node in Ubuntu using above steps.

Solution 2

There is official instruction:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

Follow https://deb.nodesource.com/setup_6.x to read shell script before execute above commands.
You always must to know what you run, especially by sudo.

Solution 3

Any version of node install is very easy

Just click Node.js scroll down and go Installation instructions and chose which version you want to install

To Install 12.x version of node:

  1. Open your terminal [Ctrl+Alt+t]
  2. execute below command

Using Ubuntu

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

or

Using Debian, as root

curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

Solution 4

To remove previous version use command

sudo npm cache clean -f
sudo npm install -g n

and then for latest version

sudo n latest

Or for stable version

sudo n stable

Solution 5

By far the most convenient way to install and manage node versions on your machine is the Node Version Manager a.k.a nvm. Just follow the installation instructions in the repo and after you have it installed run

nvm install 6.2.0
Share:
12,816
Aman Gupta
Author by

Aman Gupta

I work as a software developer. Currently I am working on MEAN stack. I also have worked with Python and React js.

Updated on June 13, 2022

Comments

  • Aman Gupta
    Aman Gupta almost 2 years

    I want to install the latest node (v6.2.0 at the time of writing) on Ubuntu. But as I do

    sudo apt-get nodejs
    

    This installed v0.10.37.

    Can you please help me in installing the latest version of node js and also npm latest version?

  • Aman Gupta
    Aman Gupta almost 8 years
    after running these commands, node -v gives No such file or directory
  • vp_arth
    vp_arth almost 8 years
    in ubuntu it becomes nodejs. Some naming conflicts.
  • Aman Gupta
    Aman Gupta almost 8 years
    this also gives me 0.10.37 older version.
  • vp_arth
    vp_arth almost 8 years
    Your legacy nodejs is still here. Run /usr/bin/nodejs -v and remove /usr/local/bin/nodejs after success.. I don't know way to correct uninstall legacy nodejs, may be apt-get remove nodejs-legacy
  • vp_arth
    vp_arth almost 8 years
    I can't to find .deb download by your link
  • vp_arth
    vp_arth almost 8 years
    Also sudo rm -rf $HOME/{local,lib,include,node*,npm,.npm*} row in reinstall script. Why want it to force(and silent) remove my ~/lib folder?
  • Aman Gupta
    Aman Gupta almost 8 years
    I have installed node v6.2.0. How do i install npm(the latest version)
  • vp_arth
    vp_arth almost 8 years
    run npm -g install npm twice
  • Ashutosh Ranjan
    Ashutosh Ranjan over 6 years
    Since node is installed @ /usr/local/bin/ we can use follwing command to remove node completely: rm -rf /usr/local/bin/node. This should work.
  • Rohan 'HEXcube' Villoth
    Rohan 'HEXcube' Villoth about 6 years
    @Shqear You've to close and reopen Terminal for the nvm command to be available