How to Install Node.js and npm in Linux?

The JavaScript programming language is so popular that it creates entire platforms for creating software. Among them, Node.js stands out, which allows JavaScript to use I/O using its API, use external multilingual libraries, etc. This article describes how to install Node.js and npm (its package manager) on Ubuntu and other GNU/Linux distributions.

Install Node via PM

Most modern GNU/Linux systems have a stable version of this platform in their repositories. Therefore, it is enough to execute the installation command.

Npm is needed to add third-party packages to Node.

Note! On some systems, npm needs to be installed as a separate package. Usually, the necessary developer tools and additional platform modules are loaded with it.

Debian-based apt update && apt install nodejs npm
Arch-based pacman -Sy && pacman -S nodejs npm
Gentoo emerge nodejs
Void Linux xbps-install -Sy nodejs

To view the platform’s version, run:

node --version

install node linux

The npm version can be recognized in the same way:

npm --version

install nodejs ubuntu

Manual Download

This method is basic to “Red Hat”-based systems. The following steps add the repository of the newest Node’s version and then install it.

curl -sL https://rpm.nodesource.com/setup_12.x | bash -

yum install -y nodejs

There is the newest version for Ubuntu:

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

apt install -y nodejs

Important! Node 10.x and below is not working on 32-bit systems.

Using nvm

Node Version Manager manages multiple platforms on a single computer. In order for it to work in the OS, development tools in C must be installed. In Debian-based OS, the packages are build-essential checkinstall libssl-dev

READ ALSO:  How to Rename Mac Computer?

Then write the line to load the text for install nvm:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

After that, restart the console.

For installing a specific platform, simply specify it as a parameter:

nvm install 12.11.1

install npm ubuntu

You can also see a list of already installed versions of Nodes:

nvm ls

install npm linux

Option use allows selecting a working version:

nvm use 12.11.1

node js linux

For deleting a specific version, you must deactivate and uninstall it:

nvm deactivate 12.11.1

nvm uninstall 12.11.1

install node on linux

Additional information and some nuances of managing the platform on various operating systems can be found in README.md on the project’s Github page.

Leave a Reply

Your email address will not be published. Required fields are marked *