node.jsubuntu

Nodejs - how to uninstall older version of nodejs and install new version of nodejs in ubuntu


my react project need updated nodejs. so how i can reinstall my node js to latest version in Ubuntu 16.04.

my current node version is

node -v
v6.0.0

my current npm version is

npm -v
3.8.6

ideally i want to reinstall my nodejs, node & npm to its newest version.


Solution

  • Uninstall NodeJS from Ubuntu

    The command will remove the package but retain the configuration files.

    sudo apt-get remove nodejs
    sudo apt-get autoremove
    

    To remove both the package and the configuration files run:

    sudo apt-get purge nodejs
    sudo apt-get autoremove
    

    Install NodeJS on Ubuntu

    Adding the NodeJS PPA to Ubuntu

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

    After successfully adding the NodeJS PPA, It’s time now to install NodeJS using the command below.

    sudo apt-get install nodejs
    

    Verfiying the version of NodeJS and NPM

    node -v
    npm -v
    

    More Info: http://www.rscoder.com/2020/04/how-do-i-completely-uninstall-nodejs.html