I ran into this problem myself a month ago. I also couldn't understand why a version of Ubuntu that was still actively supported would include versions of Node and npm that were not being supported. In the end I realized that along with wanting multiple versions installed simultaneously (e.g. LTS doesn't actually specify a single version - v16 is "Active LTS" and both v14 and v12 are currently "Maintenance LTS", and v16 comes with a version of npm which uses a different lockfileVersion than will be used by those who installed an LTS Node more than a few weeks ago). I was more comfortable installing the thousands of dependencies using an npm that did not have superuser privileges.
Since you felt that you'd looked at the entire web before coming here, you likely found the Node download page also mentioned in the comments, but (like me) didn't want to either manually check for security updates, or continue using an insecure version after they were released. Node does document how to do this in a page mentioned from the bottom of the Downloads page. You may or may not have found the npm install instructions, which partially disagree with the Node instructions despite it being difficult to use one without the other.
If you like Snaps then you can use these. As it was the only option listed specifically for Ubuntu, I started with this, but I don't like the way that snaps are installed as separate mounts and clutter my df output. I think I gave up when I needed to compare different versions and nvm was again recommended.
n
is also mentioned in the package managers page but I didn't like the circularity of needing to install a different version of npm in order to install the version manager that would install the one that I wanted.
As was recommended in another answer, I eventually used nvm
. It downloads and selects between the various versions of node for you, and has options to upgrade npm to a more recent version than ships with Node. It knows which the LTS versions are and lets you distinguish them by codename or version number. However, it is a shell script which will make things more difficult if you are using a non-POSIX shell. It doesn't have an Ubuntu or Debian package, but they have instructions for a git install which makes it easier to upgrade.
You complained that the apt
version of Node is still installed when using n
. This might be a problem if you install something else using apt that depends upon Node/npm, which might find the "system version" rather than the more recent one installed using n
. Coming from the Python world this is why I never installed pip
using apt
: I would create virtual environments and use pip from within them. If I ever try to pip install
something outside of a virtual environment then it fails because there is no system pip
to install with. I use apt
to install the different Python versions and get pip from them.