By Arif Bacchus
Your changes have been saved
Email is sent
Email has already been sent
Please verify your email address.
You’ve reached your account maximum for followed topics.
Follow
Followed
Follow with Notifications
Follow
Unfollow
Link copied to clipboard
Sign in to your XDA account
Node.js is one of the most popular tools used by developers. It's cross-platform, which means it is also available on great Linux distributions like Ubuntu. Unfortunately, Node.js isn't installed by default on Linux, so if you're hoping to use the open-source JavaScript runtime environment on your system, there are a few extra steps that you're going to have to take.
Using the package manager
For most beginners, the easiest way to install Node.js is to use the package manager and the terminal because it's available through the default repositories on Linux. This might not be the latest version, but don't worry since it'll still be stable, and you don't have to enter extra code to grab it. There are various commands depending on which Linux flavor you're using:
- For Arch Linux, use: sudo pacman -S nodejs npm
- For Debian, Ubuntu, or Linux Mint, use the command: sudo apt-get install nodejs npm
- For REHL, CentOS, AlmaLinux, and Rocky Linux, first, enable EPEL with the command sudo dnf install epel-release. Then, run the command sudo dnf install nodejs npm.
- On Fedora, use: sudo dnf install nodejs npm
If you want to see if Node is installed properly, you can run the command node -v or node --version.
If you're still having issues, you can follow the steps on the Node.js website for your distribution. We picked some of the most popular distributions, as seen above, but there are many others.
Using NVM
A better way to install Node.js is by using Node Version Manager (NVM). This is a bash script that will be run through the terminal once you open it and allows you to use and manage multiple Node.js versions and switch between them. If you opt to use this method, there's a chance you'll run into fewer permission issues, so it's worth using if you don't mind a few extra steps.
- If Curl is not installed, run the command: sudo apt install curl
- Now, run: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- Restart your terminal.
- Confirm if NVM is installed with: command -v nvm
- Run this command to see all Nodejs versions: nvm ls-remote
- Choose the version you want to install: We suggest the latest version. The command will be nvm install node to grab the latest version.
- If you want a legacy version, use the command nvm install v9.3.0, and replace the version number with the one you want.
Once you install, you can check to see the installed Node versions with the command nvm list. You also can check the installed version with node -v or node --version. If you want to run a specific node version, use the command nvm run node v17.0.0, replacing v17.0.0 with the actual version. If you want to set a specific version of node as default, meanwhile, use the command nvm alias default v18.7.0.
Just one way to develop on Linux
Using Node.js is just one thing that we suggest checking out on Ubuntu. Many other developer tools run on the operating system. For example, you might want to use AWS CLI if you're working on DevOps. You might also want to use tools like Nginx or MongoDB for web serving and managing document databases. Even a tool like Apache is useful. As you can tell, Ubuntu is the place to be for development, and there are nearly endless possibilities.
Your changes have been saved
Email is sent
Email has already been sent
Please verify your email address.
You’ve reached your account maximum for followed topics.
Follow
Followed
Follow with Notifications
Follow
Unfollow
Readers like you help support XDA. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.