This tutorial provides a comprehensive guide to installing Node.js on Rocky Linux 8, enabling you to set up a robust environment for developing JavaScript applications.
rocky linuxNodeJS
XXLarge
VPS
6
vCPU
24 GB
Memory
240 GB
NVMe Disk
12288 GB
Traffic
56.90€
/month
* Up to 12 vCPU, 72GB RAM and 720GB NVMe Disk Space
#### Prerequisites
Before you begin, ensure you have:
- A server running Rocky Linux 8
- A user account with sudo privileges
- Basic familiarity with the command line
#### Step 1: Install Node.js Using NVM (Node Version Manager)
First, install NVM (Node Version Manager), which simplifies Node.js installation and management:
```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
```
Close and reopen your terminal to start using NVM, or run:
```bash
source ~/.bashrc
```
#### Step 2: Install Node.js
Use NVM to install the latest LTS (Long-Term Support) version of Node.js:
```bash
nvm install --lts
```
This command installs the latest LTS version of Node.js. You can also install a specific version by replacing `--lts` with the version number, like `14.17.0`.
#### Step 3: Verify Node.js Installation
Verify that Node.js and npm (Node Package Manager) are installed correctly:
```bash
node --version
npm --version
```
You should see output similar to:
```
v14.17.0
6.14.13
```
#### Step 4: Set Default Node.js Version (Optional)
If you installed multiple Node.js versions using NVM, set the default version to use:
```bash
nvm alias default
```
Replace `` with the version you want to use by default, such as `lts/*` for the latest LTS version.
#### Conclusion
You have successfully deployed Node.js on Rocky Linux 8 using NVM. Node.js is now installed and ready for developing and running JavaScript applications on your server.
**Additional Resources:**
- **Node.js Official Documentation:** [https://nodejs.org/](https://nodejs.org/)
- **NVM GitHub Repository:** [https://github.com/nvm-sh/nvm](https://github.com/nvm-sh/nvm)
- **Rocky Linux Documentation:** [https://docs.rockylinux.org/](https://docs.rockylinux.org/)