Installing Node.js on Ubuntu 18.04
Node.js is a free JavaScript runtime for building scalable network applications. It is used for backend applications, microservices, web scrapers, GraphQL APIs and server-side rendering (SSR) of frontend apps.
npm is the default package manager for Node.js and the largest software registry in the world.
There are two ways to install Node.js and npm on Ubuntu: from the NodeSource repository (recent versions) or from the standard Ubuntu repository (older, but tested with your release).
Note: Ubuntu 18.04 reached the end of standard support in 2023, and NodeSource no longer builds packages for it. On Ubuntu 18.04 use the Ubuntu repository method, or better, move to Ubuntu 22.04 or 24.04, where both methods work.
Install Node.js and npm from NodeSource
At the time of the update, Node.js 24 is the active LTS version. Odd-numbered versions (17, 19, 21 and so on) never become LTS, so use an even-numbered version for production. To install another version, change the number in setup_24.x.
First, add the NodeSource repository:
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -Then install Node.js. npm is installed together with it:
sudo apt-get install -y nodejsCheck the Node.js and npm Versions
node -v
npm -vInstall Node.js and npm from the Ubuntu Repository
You can also install Node.js and npm from the default Ubuntu repository:
sudo apt-get update
sudo apt-get install nodejs npmCheck the versions the same way. On older Ubuntu releases the command may be called nodejs instead of node:
node -v || nodejs -v
npm -vConclusion
You have installed Node.js and npm on your Ubuntu server. If you need a server for your Node.js application, take a look at our Ubuntu VPS plans. Feel free to contact our support team if you have any problems with the installation.
Blog