skip to Main Content

I have node version v14.21.2 in my linux system. I have applied following code for upgrading node version in terminal but its still showing older version-
sudo apt-get install nodejs

I have previously node version v14.21.2. after upgrading it still showing older version.

2

Answers


  1. Use nvm to properly upgrade node

    If you have v14.21.2 and want to install v16.15.0 then

    nvm install v16.15.0
    

    To delete old version global packages

    node install new_version --reinstall-packages-from=old_vesion
    

    If you don’t have nvm then

    npm i -g nvm
    
    1. To install latest version nvm install node or LTS by nvm install --lts
    2. To switch default version globally nvm alias default x.y.z
    3. To use particular version nvm use version
    4. To delete nvm uninstall verison
    Login or Signup to reply.
  2. When you execute the command:

    sudo apt-get install nodejs
    

    You’re actually getting the default version of Node.js from Ubuntu’s repository of software sources.

    Given that we don’t know your version of Ubuntu and therefore can’t be sure what version of Node you have installed when you run the command.

    So you can try to update the software source via the command:

    sudo apt update
    

    Or I would recommend using the NodeSource source repository

    curl -sL (https://deb.nodesource.com/setup_14.x) | sudo -E bash -
    sudo apt install nodejs
    

    This command allows you to specify the Node.js repository you want to install and add it to the Ubuntu repository, and install it via apt

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