⚡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
Open your browser on the VPS
Go to nodejs.org
Download the LTS version (the one with the long-term support label)
Step 2: Run the installer
Double-click the downloaded
.msifileAccept the license agreement
Keep the default installation path (
C:\Program Files\nodejs\)In the Custom Setup screen, make sure npm package manager is checked
Check Automatically install the necessary tools (this adds Chocolatey and Python for native modules)
Click Install
Step 3: Verify the installation
Open a new Command Prompt or PowerShell:
node --version
npm --versionYou should see version numbers for both.
Step 4: Create a test project
Now create a simple web server. Create a file called server.js:
Run it:
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:
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:
Start your app with PM2:
Save the process list so it restarts on reboot:
Install PM2 as a Windows service for automatic startup:
Or use the Windows Task Scheduler to run PM2 at startup.
Step 7: Installing Yarn (optional)
Some projects use Yarn instead of npm:
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:
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:
Download the latest installer from github.com/coreybutler/nvm-windows
Run the installer
Open a new PowerShell as Administrator
Install multiple versions:
Switch between them:
Check the active 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:
Useful npm commands
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.
Last updated