> For the complete documentation index, see [llms.txt](https://docs.ititanhosting.ro/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ititanhosting.ro/docs/english/vps/windows/how-to-install-nodejs-on-windows-server.md).

# How to install Node.js on Windows Server

Node.js brings JavaScript to the server side. It is the foundation for many modern web applications, API servers, and development tools. Installing it on Windows Server is straightforward.

### Step 1: Download the installer

1. Open your browser on the VPS
2. Go to [nodejs.org](https://nodejs.org)
3. Download the **LTS** version (the one with the long-term support label)

### Step 2: Run the installer

1. Double-click the downloaded `.msi` file
2. Accept the license agreement
3. Keep the default installation path (`C:\Program Files\nodejs\`)
4. In the **Custom Setup** screen, make sure **npm package manager** is checked
5. Check **Automatically install the necessary tools** (this adds Chocolatey and Python for native modules)
6. Click **Install**

### Step 3: Verify the installation

Open a new Command Prompt or PowerShell:

```powershell
node --version
npm --version
```

You should see version numbers for both.

### Step 4: Create a test project

```powershell
mkdir C:\myapp
cd C:\myapp
npm init -y
```

Now create a simple web server. Create a file called `server.js`:

```javascript
const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('ITITAN Hosting Windows VPS running Node.js!\n');
});

server.listen(3000, () => {
  console.log('Server running on port 3000');
});
```

Run it:

```powershell
node server.js
```

Open your browser and go to `http://localhost:3000`. You should see the message.

### Step 5: Open the port in the firewall

To access your Node.js app from outside the VPS, open port 3000:

```powershell
netsh advfirewall firewall add rule name="Node.js App 3000" dir=in action=allow protocol=TCP localport=3000
```

Now try accessing `http://your-server-ip:3000` from your own browser.

### Step 6: Keep your app running with PM2

Node.js apps stop when you close the terminal. PM2 keeps them running and restarts them if they crash.

Install PM2 globally:

```powershell
npm install -g pm2
```

Start your app with PM2:

```powershell
pm2 start server.js --name myapp
```

Save the process list so it restarts on reboot:

```powershell
pm2 save
```

Install PM2 as a Windows service for automatic startup:

```powershell
pm2-installer
```

Or use the Windows Task Scheduler to run PM2 at startup.

### Step 7: Installing Yarn (optional)

Some projects use Yarn instead of npm:

```powershell
npm install -g yarn
yarn --version
```

### Step 8: Installing native build tools

If you plan to use packages that need native compilation (like `bcrypt` or `sharp`), you need the Windows Build Tools:

```powershell
npm install -g windows-build-tools
```

This installs Visual C++ build tools and Python. It takes a few minutes.

### Managing multiple Node.js versions

If you work on projects that need different Node.js versions, use `nvm-windows`:

1. Download the latest installer from [github.com/coreybutler/nvm-windows](https://github.com/coreybutler/nvm-windows)
2. Run the installer
3. Open a new PowerShell as Administrator

Install multiple versions:

```powershell
nvm install 20.11.0
nvm install 22.0.0
```

Switch between them:

```powershell
nvm use 20.11.0
nvm use 22.0.0
```

Check the active version:

```powershell
node --version
```

### Common issues

**"node is not recognized"** Close and reopen your terminal. The PATH variable needs to refresh after installation.

**Permission errors** On Windows, avoid installing global packages with sudo equivalents. If you get EACCES errors, make sure you are running PowerShell as Administrator.

**Port already in use** If port 3000 is already taken, use a different port or stop the other application:

```powershell
netstat -ano | findstr :3000
taskkill /PID <PID> /F
```

### Useful npm commands

| Command                 | What it does                |
| ----------------------- | --------------------------- |
| `npm init -y`           | Create a new package.json   |
| `npm install express`   | Install a package           |
| `npm install -g pm2`    | Install a package globally  |
| `npm update`            | Update all packages         |
| `npm outdated`          | Check for outdated packages |
| `npm uninstall express` | Remove a package            |

### Conclusion

Node.js is installed and ready on your Windows VPS. You can now run JavaScript applications, API servers, and web apps. With PM2 managing your processes, they will stay online even after you disconnect.
