SIGN IN / UP
    opened image

    Node.js is a jаvascript runtime that allows you to run jаvascript code outside of the browser, including on the server. It is widely used to build web applications and server applications. In this article, we'll walk through how to install Node.js on Windows Server 2019.

    Downloading the Node.js Installer

    The first step is to download the Node.js installer from the official website. You can find the installer at https://nodejs.org/en/download/. Download the installer for Windows. In this article, we will use version 18.14.2.


    Installing Node.js

    Once you've downloaded the Node.js installer, run it. The installation wizard will open. Click "Next" to continue.

    On the next page, you must read and accept the license agreement. If you agree to the terms, select "I accept the terms in the License Agreement" and click "Next".
    You will then see the component selection page. In this article, we will only install Node.js. Leave all components selected and click Next.



    On the next page, you will see a dialog for selecting the installation of all necessary components. Check the box and click "Next".


    Then click "Install".

    Installation may take several minutes. When the installation is complete, click "Finish".

    After successful installation, additional software will be installed.




    Checking the installation

    Once Node.js is installed, you can check that everything is working by launching a command line and typing "node -v". If everything is set up correctly, you should see the version of Node.js you have installed.
     

    node -v
    




    Installing additional modules

    Node.js comes with many built-in modules, but you may need to install additional modules to develop applications. To do this, use the npm package manager that comes with Node.js.


    To install a module, open a command prompt and type "npm install <module name>". For example, to install the MongoDB database module, you would type "npm install express ".

     

     

     

    npm install express
    

     




    Firewall settings

    After installing Node.js on Windows Server 2019, you may need to configure the firewall to allow incoming connections on the port your Node.js application uses. By default, Node.js uses port 3000, but you can change this in your application.

    To configure the firewall, open the "Windows Security Control Center" and select "Advanced Windows Firewall Settings". Click "Add Rule" and select "Port".

    In the next dialog, select "TCP" and enter the port number your Node.js application uses. You can also specify a range of ports if your application uses multiple ports. Click next.

    In the next dialog box, select "Allow connections" and click "Next".

    In the last dialog box, enter a name for the rule and click Finish.

    Or use a simple PowerShell command:

     

     

     

     

    netsh advfirewall firewall add rule name="port-3000" dir=in action=allow protocol=TCP localport=3000
    

     




    Running a Node.js Application

    Once you have installed Node.js on Windows Server 2019, configured the firewall, and installed all required modules, you can start your application.
    To run the application, open a command prompt, navigate to the directory where your application is located, and enter the command "node <filename>".

    For example, if your application is in the file "js_sample.js", you would enter the command "node js_sample.js".

     

     

     

     

    node js_sample.js
    

     



    Once the application is launched, it will be available at "http://localhost:3000" if you use the default port 3000.


    By following the instructions above, you will be able to install and set up Node.js on your server and start developing applications on this platform.