Node.js
Node.js is a JavaScript runtime environment popular with developers for network applications that works event-based. While JavaScript is typically executed on the client side in a browser, Node.js runs on the server – like PHP, for example – and also provides a web server for this purpose.
Unlike PHP, which uses a separate CPU thread for each request that is blocked until the request is answered, Node.js works asynchronously (“non-blocking I/O”) via an “event loop” in a single thread and thus uses server resources more sparingly and efficiently – which is why PHP has also received ansynchronous extensions in the meantime.
npm and dependency hell
In addition, Node.js comes with the package manager npm, which in turn provides access to a veritable universe of JavaScript packages, the npm registry, that can be used to solve every conceivable task. Sounds like a perfect solution for JavaScript programmers, may lead otherwise into the so called “dependency hell”.
There have been isolated cases of compromised packages, and in the end of 2021 a 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.
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.
Despite everything: Node,js and its registry, now operated by Github and thus Microsoft, enjoy so much popularity in the JavaScript world, that even applications that do not need Node at all are now installed on top of it. Popular examples include frontend frameworks like ReactJS.
Release schedule
New versions of Node.js are released every six months and are then considered current for six months. Only releases with even version numbers receive a long-term support (LTS) of 30 months, consisting of 12 months in active state and 18 month in maintenance state.
Bottom line: In production, only even-numbered releases should be used. The may be replaced after one year with the next even-numbered release or kept for another one and a half year including support.
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.
Here is an example of how to set up the nodesource repository using a script provided by them for LTS version 22, which came to late to be included in Ubuntu 24.04 LTS:
curl -sL https://deb.nodesource.com/setup_22.x | sudo -E bash - sudo apt install nodejs npm