Node.js is a popular runtime environment that enables the development of scalable and high-performance server-side applications using JavaScript. In this guide, we will show you how to install Node.js on Linux systems, including Ubuntu, Debian, and CentOS.
Table of Contents:
Install Node.js Using the Default Package Manager
- On Ubuntu/Debian:
sudo apt update sudo apt install -y nodejs npm
Check version:
node -v npm -v
- On CentOS/RHEL:
sudo yum install -y epel-release sudo yum install -y nodejs npm
node -v npm -v
Note: Default repositories may not provide the latest version.
Install Node.js Using NodeSource Repository (Recommended for Latest Version)
- On Ubuntu/Debian:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt install -y nodejs
- On CentOS/RHEL:
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash - sudo yum install -y nodejs
- Verify installation:
node -v npm -v
Install Node.js Using NVM (Node Version Manager)
NVM allows you to install and manage multiple Node.js versions on the same system.
- Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash source ~/.bashrc
- Install Latest Node.js:
nvm install node
- Install a Specific Version:
nvm install 18 nvm use 18
- Check:
node -v npm -v
Conclusion:
You can now run Node.js applications on your Linux server. Use the default package manager for quick setup, NodeSource for the latest stable release, or NVM for managing multiple versions. Node.js makes it easier to build fast, scalable, and modern applications. For any issues, contact our support team.
For better performance and scalability, consider using a Linux VPS environment designed for application hosting.
Want to check your server setup too? Learn HHow to check the Apache version via the shell