1. Use apt to install
If your Linux system has apt command, such as Ubuntu system, you can use apt to quickly install and uninstall
sudo apt update
sudo apt install nodejs
sudo apt install npm
node -v
Although it is very convenient to install nodejs through apt, the installed version is not the latest. If it does not meet your needs, please take a look at the following method
2. Download the installation package from the official website
Go to the official website of nodejs https://nodejs.org/en/download and download a Linux Binaries version suitable for your system. As for whether to choose X64 or arm, it depends on your CPU
For example, what I downloaded here is Linux Binaries (x64)
mkdir /usr/local/nodejs && cd /usr/local/nodejs
wget https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-x64.tar.xz
tar -xvf node-v18.16.0-linux-x64.tar.xz
cd node-v18.16.0-linux-x64
ln -s /usr/local/nodejs/node-v18.16.0-linux-x64/bin/node /usr/local/bin/node
ln -s /usr/local/nodejs/node-v18.16.0-linux-x64/bin/npm /usr/local/bin/npm