The Node.js platform is available for a range of operating systems, from Windows to Ubuntu and OS X. Here I am providing the step-by-step guide of how to install node js in the windows operating system.
Lets start by downloading the latest version of node.js from the official website https://nodejs.org/en/ .
Download the recommended version, in our case, it is 12.14.1 LTS.
Click on the downloaded .exe file and start installing the Node.Js.
Install npm on Windows
Install npm Package Manager using node.js MSI installer
As you can see in the above screenshot. it is also going to install the npm package manager in our system.
Lets click Next and continue the installation process.
If you click on this checkbox it is going to install the chocolatey in your machine.
Windows package manager
Chocolatey is a command-line application installer for Windows-based on a developer-centric package manager called NuGet. Unlike manual installations, Chocolatey adds, updates, and uninstalls programs in the background requiring very little user interaction.Click Next to continue to the next screen
Click on Install to finish the installation process
We are done with the installation process of Node.js and npm. Open a command prompt and type npm –version to ensure the successful installation of npm.
Creating node.js hello world
Open Notepad and paste the below code to run the Node application.
var http = require("http"); http.createServer(function (request, response) { // Send the HTTP header // HTTP Status: 200 : OK // Content Type: text/plain response.writeHead(200, {'Content-Type': 'text/plain'}); // Send the response body as "Hello World" response.end('Hello World from Beetechical\n'); }).listen(8081); // Console will print the message console.log('Server running at http://127.0.0.1:8081/');
Save the file with .js extension to run the file on a node server.
Open the command prompt and navigate to the file location by using the cd command.
Once you run the file using node, You should be able to open the application on http://127.0.0.1:8081 or http://localhost:8081.
So, we are able to run our javascript application using a node server.
Conclusion
We hope this tutorial will help you to install node js in the windows environment. Also, how to write your first node js application and test it locally.
Comments are closed.