0

I did as per the solution given in How can I update my nodeJS to the latest version?

But when I check nodejs --version

I get v8.10.0

And when I install using this command sudo n latest I get installed : v13.8.0 (with npm 6.13.6)

I have the same version problems with node and npm too, the latest verion installed is not reflected.

whereis nodejs I am getting this output: nodejs: /usr/bin/nodejs /usr/lib/nodejs /usr/share/man/man1/nodejs.1.gz

I tried uninstalling nodejs and installing again the same thing happens. Is this a problem with ubuntu?

  • please [edit] and paste the output of whereis nodejs – cmak.fr Feb 18 '20 at 05:38
  • @cmak.fr done editing – Faiz Hameed Feb 18 '20 at 05:45
  • @karel I tried this actually , but it didnt solve the problem. I think there was some other issues. I waiting for cmak reply to my comment. Then I will try one of the solutions from the solution you have give – Faiz Hameed Feb 18 '20 at 06:56
  • I've been trying to solve this problem by installing multiple versions of node.js alongside each other so the user can select the version to use each time, but nobody wants to read it. Instead they seem to just want to dig themselves in deeper. – karel Feb 18 '20 at 10:55
  • Affer following the below answer by @cmak.fr and then curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - sudo apt-get install -y nodejs solved my issue`

    Now i have nodejs version as 8.10.0 while node version as 13.8.0 thats ok right?

    – Faiz Hameed Feb 18 '20 at 12:02

1 Answers1

1

some weeks ago i had to install a project-specific 10.x.x version
I had to :

Follow the instructions from the official documentation
https://github.com/nodejs/help/wiki/Installation

# Uninstall viaPackage installed nodejs version
sudo apt-get remove --purge nodejs

# Choose your version / architecture
# Find available versions list there:
# https://nodejs.org/en/download/releases/

VERSION=v13.8.0
DISTRO=linux-x64

# Download
wget https://nodejs.org/download/release/v13.8.0/node-v13.8.0-linux-x64.tar.xz

# Install ie extract archive to /usr/local/lib/nodejs
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs 

# Create symlinks
sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npm /usr/bin/npm
sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npx /usr/bin/npx

# Update profile
tee -a ~/.profile << ENDap
# Nodejs
VERSION=v13.8.0
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH
ENDap
. ~/.profile

# Tests
node -v
npm version
npx -v
cmak.fr
  • 8,696
  • Linux Ubuntu x64 18.04 - Thank you I will try this and update you – Faiz Hameed Feb 18 '20 at 06:33
  • I did exact steps as you posted: nodejs -v npm version:{ npm: '6.13.6', ares: '1.15.0', brotli: '1.0.7', cldr: '36.0', icu: '65.1', llhttp: '2.0.4', modules: '79', napi: '5', nghttp2: '1.40.0', node: '13.8.0', openssl: '1.1.1d', tz: '2019c', unicode: '12.1', uv: '1.34.1', v8: '7.9.317.25-node.28', zlib: '1.2.11' } – Faiz Hameed Feb 18 '20 at 06:49
  • But when i type nodejs -version i get this output: 'nodejs' not found, but can be installed with: sudo apt install nodejs – Faiz Hameed Feb 18 '20 at 06:51
  • Should I install again with sudo apt install nodejs now – Faiz Hameed Feb 18 '20 at 06:51
  • Did you create the symlinks? My answer is helpful when you need to choose a specific version. If you dont want to understand what the commands do, you'd better revert what was done and go with what karel suggested. – cmak.fr Feb 18 '20 at 07:11
  • Yes i did create sym links. I wne through exact your steps only nodejs is not installed. But node and npm versions are upgraded – Faiz Hameed Feb 18 '20 at 07:16
  • @Faiz Hameed : Oops, then is no nodejs executable... Answer updated node -v – cmak.fr Feb 18 '20 at 10:49
  • I did sudo apt install nodejs and all the node,npm and npx reverted back to old ones :( – Faiz Hameed Feb 18 '20 at 11:46
  • Affer following your answer and then curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - sudo apt-get install -y nodejs solved my issue`

    Thanks a lot]

    – Faiz Hameed Feb 18 '20 at 12:03