Search code examples
node.jsversionnpm-install

Updating node version


I have updated Node js by following these steps:

sudo npm install -g n
sudo n stable
sudo n latest

However when I check the version with:

node -v

or

nodejs -v

I get the old/current version which is v10.19.0

any idea why this is happening?


Solution

  • So I figured out how to to upgrade to the latest version of node js. First you need to remove the older version of node with this syntax:

    sudo apt-get purge --auto-remove nodejs
    

    Install npm with:

    sudo apt install npm
    

    For me it already installed the latest version of node js, however if it did not work for you continue by installing node with these syntaxes:

    npm install n -g
    n stable
    sudo n latest
    

    Then check your node version by running node -v