quanguyen
quanguyen

Reputation: 1463

Upgrade but console still displays old version

I want to upgrade my node from current version (7.2.1) to the latest (8.5) on my Ubuntu server.

I follow the instruction here, in Debian and Ubuntu based Linux distributions section, by running 2 commands below:

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

After installing, I check the version by: node -v, but the console still prints 7.2.1. Why is that?

I have some Node program running on Node 7.2.1. After upgrading to Node 8.5, will there by any conflicts? Should I rerun them?

Regards

EDIT: Add an example to make sure the nodejs still stays obsolete.

The major difference between node 7.x and node 8.x is async/await. So, I just write this simple example to check if node "understands" the new syntax:

getABC()

async function getABC() {
  const a = await getA()

  console.log("result: " + a)
}

function getA() {
  setTimeout(() => {
    return 5
  }, 100)
}

Result:

result: undefined

So, node on my server is not updated yet!

Upvotes: 1

Views: 123

Answers (1)

Kalana Demel
Kalana Demel

Reputation: 3266

apt-get is bugged when it comes to installing nodejs, use the following to install with nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash

nvm install 8.5.0

nvm use 8.5.0

//check with 
node -v

Upvotes: 1

Related Questions