Back to blog
January 13, 2026Guides

How to Install Node.js on Linux Server

Complete guide on installing Node.js and npm on Ubuntu and CentOS servers, including version management with NVM.

How to Install Node.js on Linux Server

Node.js is a JavaScript runtime built on Chrome's V8 engine, essential for running modern web applications, APIs, and server-side JavaScript. This guide covers multiple installation methods for Node.js on your Hiddence server.

Method 1: Install with NVM (Recommended)

NVM (Node Version Manager) allows you to install and manage multiple Node.js versions:

bash
# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

# Reload shell configuration
source ~/.bashrc

# Install latest LTS Node.js
nvm install --lts
nvm use --lts
nvm alias default node

# Verify installation
node --version
npm --version

Method 2: Install from NodeSource Repository

For Ubuntu/Debian, use NodeSource repository:

bash
# Install Node.js 20.x LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# Verify installation
node --version
npm --version

Verify Installation

bash
node --version
npm --version

# Check Node.js location
which node
which npm

Installing PM2 Process Manager

PM2 is a production process manager for Node.js applications:

bash
# Install PM2 globally
sudo npm install -g pm2

# Start your application
pm2 start app.js

# Save PM2 process list
pm2 save

# Setup PM2 to start on boot
pm2 startup
# Follow the instructions shown

# Monitor applications
pm2 monit

# View logs
pm2 logs

Configure Nginx as Reverse Proxy

Configure Nginx to proxy requests to your Node.js application:

bash
sudo nano /etc/nginx/sites-available/yourdomain.com

# Add this configuration:
server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

# Enable site and reload Nginx
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Node.js Best Practices

  • Use NVM for easy version management
  • Always use PM2 for production deployments
  • Set up proper logging and monitoring
  • Use environment variables for configuration
  • Enable HTTPS with SSL certificates
  • Implement proper error handling
  • Keep Node.js and npm updated regularly