How to Set Up Node.js on a Windows Server?

How to Set Up Node.js on a Windows Server?

As a server-side JavaScript platform, Node.js provides an open-source runtime environment for building networking applications. This platform takes advantage of a very fast Google V8 JavaScript engine and runs on various operating systems. In this tutorial, we will center the attention on how to set up a production-ready Node.js environment on a Windows server.

Note that, the Node.js or node.js project is also called as Node or node, and these terms would be used throughout this guide.

How to Get Started with Node.js?

To be Frank, Node.js is another great toolkit for developers after the appearance of Visual Studio web publishing tool. To set up Node.js is pretty simple, which won’t take more than 10 minutes of your time. In the following, let’s go over the detailed steps to set up node.js on your Windows server. Pay attention that, the general installation process is the same, no matter which OS version and operating system you’re using.

Step 1 – Download Windows Installer Package
The first thing you will need to do is install Node on your local computer. To do this, just go to this Node.js page and make a selection of the installer to download. In this example, we’d like to download the “Windows Installer” package. Make sure that you would select the most appropriate installer package for this setup process.

Download Windows Installer Package

Step 2 – Run Node.js Setup Wizard
To proceed, you should find out the downloaded installer package and double-click it to open up its setup wizard. From the following installation window, just click “Next” button and go through the whole “Setup Wizard.” If this installation progress is corrupted, then you can re-open this package and choose “Repair” option to fix potential issues.

Run Node.js Setup Wizard

Step 3 – Finish Your Installation Progress
Be sure to click the “Finish” button after the completion of this installation process. Before you start using node.js in your command, we recommend you to restart your computer. In this way, you can flush the Windows OS since it has adjusted registry files.

Finish Your Installation Progress

How to Verify Whether Node.js Is Working on Windows?

Now that you’ve installed node.js and its node package manager NPM, it’s time to check whether this project is working or not. At this place, we prefer to make a simple Node.js application for demonstration purposes.

Step 1 – Create a Node.js Application
First off, you are expected to create a local folder for this application. A location like “c:/desktop/node/test-app” will make it much easier to access your file through “Windows Command Prompt.” In the below example, we have a folder called as “test-projects” in “My Desktop” folder. Within this “test-projects” folder, we also create a subfolder labelled as “my-node-js-app”.

Create a Node.js Application

Step 2 – Set Up a Hello World Script
To ensure that your Node install can work well with Windows, just create a hello world script or a “hello-world.js” file inside the above “my-node-js-app” folder. Just copy and paste the following source code to this testing “hello-world.js” file. Beware that, the following configuration code is the official code example from Node.js.

var http = require('http');
http.createServer(function (request, response) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "");
console.log('Server running at');

Step 3 – Run Your Windows Command Prompt
Now, it’s high time to run your first node.js application. Just run the “Node.js Command Prompt” directly from your Windows “Start” menu. To find it, you can enter node.js in the “Search Programs and Files” text box.

Run Node Command Prompt

As you can see, your “Node.js Command Prompt” is a CLI (command line interface) as below. To use this CLI, just header over to the mentioned Node.js application’s folder. And then, you only need to insert the changed directory command like “cd \Desktop\test-projects\my-node-js-app” into the blank interface.

Insert Changed Directory in DLI

Step 4 – Test Hello World Script
In the meantime, you also need to type the command like “node hello-world.js” to run your “hello-world.js” file. If nothing goes wrong, the command line interface will tell you that “Server running at now. If you wish, it is possible to type in any web browser. This will open a browser window where you can see the “Hello World” text, reflecting that everything is working as expected.

Test Hello World Script

If you’ve gone through the above steps successfully, there’s nothing left to do. Till present, your Windows computer should run Node.js well, and no further configuration is required.

Note: If you are dissatisfied with Node.js and want to uninstall it, just navigate to “Start” > “Control Panel” > “Programs and Features.” From here, just select the Node.js icon and click the top “Uninstall” button. All you need to do is to follow the instructions in the pop-up dialog window.

Uninstall Your Node.js