[Linux] Ubuntu upgrade nodejs version

        When downloading nvm to manage the nodejs version, the download failed due to network factors, so a new method was used to upgrade the nodejs version.

        ​ ​ ​ First, let’s check the existing nodejs version number and find that it is 12

         We download a software package named n, n is a very convenient Node.js version management tool, similar to Ruby's rvm or Python's pyenv. It helps you easily switch and manage multiple Node.js versions on the same machine.

        Before downloading n, we need to install npm.

sudo apt install npm

        If this problem occurs during installation, just run apt-get update to update the software package and reinstall it. 

        Install n now 

sudo npm install n -g

        After the installation is complete, we can manage the nodejs version

# 升级到最新的稳定版本
sudo n stable

        ​​​​The node-v20.9.0 version was automatically installed for me

        After the installation is complete, if the display is still the previous version, use hash -r and query again.

        Of course, you can also choose the version to install. For example, I want to install an ancient version of nodejs8.17.0

sudo n 8

Guess you like

Origin blog.csdn.net/naihe_fish/article/details/134027523