1

I have tried so many solutions to install the latest version of nodes js in my system but it did not work any .Its only installing node version v5.12.0 which is not supporting vuejs.

out put of type -a node nodejs is

node is /usr/local/bin/node
node is /usr/bin/node
nodejs is /usr/bin/nodejs

And the output of apt-cache policy nodejs is

nodejs:
  Installed: 5.12.0-1nodesource1~xenial1
  Candidate: 5.12.0-1nodesource1~xenial1
  Version table:
 *** 5.12.0-1nodesource1~xenial1 500
        500 https://deb.nodesource.com/node_5.x xenial/main amd64 Packages
        100 /var/lib/dpkg/status
     4.2.6~dfsg-1ubuntu4.1 500
        500 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages
     4.2.6~dfsg-1ubuntu4 500
        500 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages

Any suggestions ?

7
  • I just followed the link still its downloaded the 5.12.0 version for me . Any suggestions ?
    – 06011991
    Jun 26, 2017 at 7:18
  • Remove version 5.12.0 and then run sudo apt-get install curl && curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - && sudo apt-get install -y nodejs
    – karel
    Jun 26, 2017 at 7:25
  • @karel : i have done the same way still the version is older one . :(
    – 06011991
    Jun 26, 2017 at 7:29
  • sudo apt-get remove nodejs npm removes the existing version of nodejs in Ubuntu.
    – karel
    Jun 26, 2017 at 7:31
  • I have done the same when i run this command curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - it says ## Installing the NodeSource Node.js v8.x repo... after running this command sudo apt-get install -y nodejs it says Unpacking nodejs (5.12.0-1nodesource1~xenial1) ... . I dont understand why its getting the older version .
    – 06011991
    Jun 26, 2017 at 7:44

7 Answers 7

4

You can try using Node Version Manager (NVM). You can find it on github here.

Briefly information to install nvm and node (see github repository for more information):

  • Install nvm:

    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
    
  • Update Ubuntu environment variables. This commands let you run nvm from any place inside your terminal:

    export NVM_DIR="$HOME/.nvm"
    
    [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
    
  • Check nvm is installed:

    nvm --version
    
  • Install latest version of node (version selected by default):

    nvm install node
    
  • Check node version:

    node -v
    

Note: if you aren't be able to open node the first time, try to close and reopen your shell.

2

Remove the Previous one using:

sudo apt-get remove nodejs npm

Re install using PPA(Current Release):

sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

For LTS:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
3
  • When i run the second command it says ## Installing the NodeSource Node.js v8.x repo... but version is 5.12.0 :(
    – 06011991
    Jun 26, 2017 at 7:22
  • try to remove the previous one , install a fresh one using above! Jun 26, 2017 at 7:30
  • Its the same case its not updating to the latest version i dont understand why ?
    – 06011991
    Jun 26, 2017 at 7:45
1

Facing the same issue not able to update from 5.12.0 to 6.x LTS version.But resolved it by following the instructions as mentioned in Nodejs.org

No need to remove the older version and all.

For upgrading to 6.x version: Run the below commands:

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

For upgrading to 8.x version: Run the below commands:

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

echo "deb https://deb.nodesource.com/node_8.x xenial main" > /etc/apt/sources.list.d/nodesource_8.x.list
curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -

apt-get --assume-yes update
apt-get --assume-yes upgrade

apt-cache madison nodejs

apt-get --assume-yes install nodejs
0

All stable releases are available as snap packages.

https://snapcraft.io/node

Command-line install:

sudo snap install node --channel=12/stable --classic

Verify versions:

node -v
npm -v

https://nodesource.com/blog/installing-nodejs-tutorial-using-snaps-on-linux

0

I would leave the version installed by your distro alone.

If you need a specific version for a development project, download the exact version you need from https://nodejs.org/en/ and un-tar the file (typically under /opt) and run it from there.

e.g.

cd /opt
wget https://nodejs.org/dist/v13.6.0/node-v13.6.0-linux-x64.tar.xz
tar xvf node-v13.6.0-linux-x64.tar.xz

node-v13.6.0-linux-x64/bin/node

Welcome to Node.js v13.6.0.
Type ".help" for more information.
> 

Good security practice to verify the shasums https://nodejs.org/dist/v13.6.0/SHASUMS256.txt.asc

If you do this, avoid using npm -g with the version not supported by you distro.

This approach ensures that any code that uses node in the rest of your system will not be caught out by finding an unsupported version. Technically this is needed if the major semver version is different from that provided by your distro, in reality running the future nodejs major versions is safe with most code.

0

Install it from the official site,

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

You are able to install other versions by simply changing the setup_12.x, 12 is the version.

Offical Link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.