Node.js is an open-source runtime environment that enables to execute JavaScript code on the server without a browser. It is built on the Chrome's V8 JavaScript engine. Node.js is often used for developing web applications. NPM is a package manager for Node.js that enables to install various packages from remote registry.
Node.js 24 is a long-term support (LTS) release. This release has various updates. For example, the V8 JavaScript engine has been updated to 13.6. This tutorial demonstrates how to install Node.js 24 and npm on Ubuntu 26.04.
Install Node.js and npm
NodeSource repository maintains Node.js 24 binary distributions. So add this repository in your system by using the following command:
curl -sSL https://deb.nodesource.com/setup_24.x | sudo bash -
Install Node.js:
sudo apt install -y nodejs
During installation, npm and Corepack are also installed automatically. There is no need to install npm or Corepack separately, as they come bundled with Node.js. The installation can be verified by checking the versions of Node.js, npm, and Corepack:
node --version
npm --version
corepack --version
Testing Node.js
Create a new main.js file:
nano main.js
Add the following a line of code:
console.log('Hello world');
Test a program with node command:
node main.js
Uninstall Node.js and npm
Disable Corepack by removing the package manager shims (e.g., Yarn and pnpm) if they are enabled:
sudo corepack disable
Remove Node.js and related dependencies by running the following command:
sudo apt purge --autoremove -y nodejs
Remove the GPG key and repository:
sudo rm -rf /usr/share/keyrings/nodesource.gpg \
/etc/apt/sources.list.d/nodesource.sources \
/etc/apt/preferences.d/{nodejs,nsolid}
Delete the Node.js cache:
rm -rf ~/.cache/node
Install older versions
Node.js 22 is an older LTS version that is still supported. It can be installed by adding the following NodeSource repository:
curl -sSL https://deb.nodesource.com/setup_22.x | sudo bash -
The 1 Comment Found
In your article, you provide a node.js installation, testing and uninstallation process because many articles only provide an installation or uninstallation process but you provide all processes in one post. so, Thank you for sharing this information.
Leave a Comment
Cancel reply