Install node.js in linux using the package manager

  • 2020-05-16 06:14:28
  • OfStack

In the online articles, the installation of node.js under linux is done with source code compilation, while the installation of node.js using their own package manager (package manager) on node's github is already provided on each system.

1. In Ubuntu, use the following command:


curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs

If you need to install local components using npm, you also need to execute the following command:


apt-get install -y build-essential

2. In Debian, use the following command:


apt-get install curl
curl -sL https://deb.nodesource.com/setup | bash -
apt-get install -y nodejs

If you need to install a local component using npm, you also need to execute the following command:


apt-get install -y build-essential

3. In RHEL, Fedora, CentOS, use the following command:


curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs

If you need to install local components using npm, you also need to execute the following command:


yum groupinstall 'Development Tools'
# The next row is in Fedora Performed in the
sudo yum install nodejs npm
# The next row is in RHEL and CentOS Performed in the
sudo yum install nodejs npm --enablerepo=epel

But in practice, in CentOS6, it's implemented


sudo yum install nodejs npm --enablerepo=epel

You can also use npm without executing an error.

4. In openSUSE and SLE, use the following command:


sudo zypper ar \
  http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_13.1/ \
  Node.js
sudo zypper in nodejs nodejs-devel

5. In Arch Linux, use the following command:


pacman -S nodejs

6. In FreeBSD and OpenBSD, use the following command:


/usr/ports/www/node
cd /usr/ports/www/node-devel/ && make install clean
# or
pkg_add -r node-devel
pkg install node
# or
pkg install node-devel

That's all for this article, I hope you enjoy it.


Related articles: