But at the end of 2014, storm clouds were gathering in the sky when leading developers, dissatisfied with the Node.js sponsor Joyent, created a spin-off called io.js. Since version 4, however, the two projects have been reunited, and the development of Node.js was placed in the hands of a foundation.
The “all you can eat” mentality, with which developers relay on the bubbling npm registry also holds dangers, however. There have been isolated cases of compromised packages, and in the end of 2021 are vulnerability was patched that seemed to be undetected for many years. In early 2022 the developer of the popular faker.js and colors.js libraries sabotaged his own packages to protest against large companies using his code without paying for it.
New versions of Node.js are released every six months and are then considered current for six months. Even version numbers also receive long-term support (LTS) of 30 months, for a total lifespan of three years. Ubuntu 22.04 still shipped the aged LTS version 12 when it was released, while Node.js’ homepage already lists version 16 as the current LTS version.
How to install node.js on Ubuntu
Nodejs can be quickly obtained from the Ubuntu package sources:
sudo apt install nodejs
This installs a maintained LTS version, but not necessary the latest, and without support directly from Ubuntu, because the package is only in the Universe repository. There are three ways to get a current version at any time:
- Enter the Nodesource repository as an additional package source and conveniently install and update node.js via apt.
- Use the Node Version Manager (nvm), a bash script, to download one or more Node versions and run them in parallel.
- Manually download and install the desired version directly from the Node.js download page.
The npm documentation recommends using nvm over an installer, because otherwise npm is installed in a local context, so that errors can occur when packages are to be executed globally. Nevertheless, here is an example of how to set up the nodesource repository using a script provided by them for LTS version 16:
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - sudo apt install nodejs npm