skip to Main Content

I start using ubuntu (22.04.1) recently. I want to install nodejs latest version (currently v18.12.1 LTS).
But my node --version showing version v12.22.9.

First I install node using sudo apt-get install nodejs. Then I re-install my node but before re-install I update my system using sudo apt update && sudo apt upgrade. But i keep getting same result. node version v12.22.9.

4

Answers


  1. Don’t use the distribution’s default, Ubuntu is extremely conservative with bumping versions of things like Node, so instead go with Node’s repository.

    The current location is documented in the installer instructions:

    curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&
    sudo apt-get install -y nodejs
    

    Where the setup_ scripts usually do a good job of getting everything properly sorted.

    For the 18 LTS version:

    curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&
    sudo apt-get install -y nodejs
    
    Login or Signup to reply.
  2. I would use nvm – Node Version Manager, see https://github.com/nvm-sh/nvm#install–update-script

    This has a couple of advantages: you don’t change the system’s node version (which might be used elsewhere) and you may select a distinct (older or newer) version of node accompanied by appropriate installations of npm, yarn, a.s.o. It’s simple to install "global" packages just locally (kind of oxymoron…) for your user. You don’t need root permission for these.

    Login or Signup to reply.
  3. 1-Install CURL if you don’t have:

    sudo apt-get install curl

    2-Run the following command to add the PPA to the Ubuntu system:

    curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash – &&

    3-After successfully adding the PPA to the system, execute the command below to install Node on Ubuntu:

    sudo apt-get install nodejs

    4-check the version number of the installed software for node :

    node -v

    Login or Signup to reply.
  4. The current LTS version can be installed via

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

    In difference to the already provided answers, this evergreen link will always install the current long term supported version. So you don’t need to tweak your script every couple month.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search