Home >> Tutorials >> Install Node.js Linux

Install Node.js on Linux

1. Install Node js using your Distribution's Package Manager
On Arch Linux:
sudo pacman -S nodejs npm
On Debian, Ubuntu, Linux Mint:
sudo apt-get install nodejs npm
On RHEL, CentOS:
sudo yum install epel-release
sudo yum install nodejs npm
On Fedora:
sudo dnf install nodejs npm

Note: Since the packages from the default repositories are outdated, you will get the following error when you try to install any NodeJS modules using npm.

/usr/bin/env: ‘node’: No such file or directory

To solve this error, you need to create symlink as shown below.

sudo ln -s /usr/bin/nodejs /usr/bin/node
2. Install Nodejs from NodeSource
On Debian, Ubuntu distributions:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install nodejs npm
On RHEL, CentOS:
curl --silent --location https://rpm.nodesource.com/setup_9.x | sudo bash -
yum install nodejs npm
3. Install Nodejs using NVM (Recommended method)

This is the best way to avoid permissions issues. NVM (Node Version Manager) is a bash script used to manage multiple Node.js versions. It allows us to install, uninstall node.js, and switch from one version to another. Good thing is we can install to any available Node.js version of our choice, using NVM.

Full Stack Tutorials

Author @FullStackTutorials | View all Articles