Install Nodejs on Ubuntu 20 Rumi, December 7, 2024 Installing Node.js and npm from NodeSource NodeSource is a company focused on providing enterprise-grade Node support. It maintains an APT repository containing multiple Node.js versions. You can use this repository to install any version of Node.js you need. The first step is to install the dependencies necessary to add a new repository . Most likely, you will already have those packages installed on your system, but some packages may be missing: sudo apt updatesudo apt install ca-certificates curl gnupg Next, import the Nodesource repository’s GPG key to your system: sudo mkdir -p /etc/apt/keyringscurl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg At the time of writing, NodeSource repository provides the following versions: v21.x - The latest stable version. v20.x - The latest LTS version. v18.x - The previous LTS version. v16.x - EOL-ed We’ll install Node.js version 20.x. If you need another Node.js version, for example, 18.x, change the NODE_MAJOR=20 with NODE_MAJOR=18. Run the following command to create the NodeSource repository file: NODE_MAJOR=20echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list Once the repository is enabled, install Node.js and npm: sudo apt updatesudo apt install nodejs The nodejs package contains both the node and npm binaries. Verify that the Node.js and npm were successfully installed by printing their versions: node --version v20.10.0 npm --version 10.2.3 To be able to compile native addons from npm, you’ll need to install the development tools: sudo apt install build-essential Src: https://linuxize.com/post/how-to-install-node-js-on-ubuntu-20-04/ Administrations Collected Articles