How to Download and Install Node JS | NPM on Windows | Localhost

Home >> Blog >> How to Download and Install Node JS | NPM on Windows | Localhost

In this article, you will learn how to download and install node.js on windows 10 localhost.

Steps by Step Guide on How to Download and Install Node JS on Windows | Localhost:
  1. Download Node JS Windows Installer (.msi) from NodeJS Official Website - nodejs.org.
  2. Now, Run the Node JS Windows Installer (.msi installer) and follow the prompted steps in the installer wizard.
  3. Congrats!, Now Node JS installed on your windows localhost successfully with NPM.
Now, It's time to check and verify the Node JS and NPM Verison installed on your windows localhost.

Open either Windows Command Prompt (CMD) or Open GIT Bash Terminal, and type the following commands.

  1. node -v //it will show you installed version of Node JS.
  2. npm -v //it will show you installed version of NPM (Node Package Manager).

If by running the above command you are able to see the node.js and npm versions then node.js and npm installed succ on your windows localhost.

Important Notes:
  1. Together with Node JS, NPM also installed automatically by default.
  2. Node Package Manager (NPM) – It provides you feature to easily install any Packages/Modules like ExpressJS, Nodemon, PM2, axios, mongoose, moment, etc. using NPM from the opensouce repository - https://www.npmjs.com/
Example:
// Install express.js as dependency >> npm install express --save // Install nodemon as devDependency >> npm install nodemon --save-dev
Now, Let's Create and RUN NodeJS Server on your Windows | Localhost
  1. Go to any of your directory in any drive on your local windows machine.
  2. Now, create a file (for example) C:\projects\test.js.
  3. Now, put the below code in that file.
    var http = require("http"); http .createServer(function (req, res) { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello World\n"); }) .listen(3000, "127.0.0.1"); console.log("Server running at http://127.0.0.1:3000");

    Note - You can change port from 3000 to any other if required

  4. Now, Open cmd (Command Prompt) and run following command
    >> cd C:\projects >> node test.js
  5. Go to the your browser and open this address in your browser: http://127.0.0.1:3000

Note: I have given the above example to just show you how to create a NodeJS server locally. but it always recommended to create your NodeJS Projects using npm init

You may also like - Node.js Tutorial
You may also like - React.js Tutorial
You may also like - Node.js Interview Questions And Answers
You may also like - React.js Interview Questions Answers