curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs
After running the installation, npm and node commands should be available.
sudo npm install -g npm@latest
Update npm to the latest version.
npm audit fix
Address possible vulnerabilities.
sudo npm install -g n
Install node's package management tool n.
sudo n latest
Install the latest version of node (LTS version is recommended).
-----------------------------------------------------------
Additional:
sudo n lts
Install the latest LTS version of node.
sudo n
Enter n's graphical interface and select the version you want to use.
sudo n prune
Removing other versions can save memory space.