Home >> Latest Articles >> How to install node js on xampp localhost

How to install node js on xampp localhost

How to install node js on xampp localhost: node js download and follow the following steps - how to install node js on windows

It's really easy to install Node js if you are using Xampp or Wamp etc.

Because unlike old days, now Node js org has created Windows Installer (.msi).

If don't have Xampp instaaled on your localhost, Download & Install Xammp

Steps: How to Install Node js on Localhost:
  1. Download Windows Installer (.msi) from it's site official website Node Js Official Website.
  2. Run the Installer (.msi installer that you downloaded)
  3. Follow the prompts steps in the installer.
  4. Congrats!, now you have installed Node.js successfully with NPM.
  5. Keep your Apache and Node ports different. Declare Node port other than 80 or 8080 while creating server in Node because these are the default ports of Apache.
  6. Run - node -v on cmd to test the version of Node Js.
  7. Run - npm -v on cmd to test the version of NPM (Node Package Manager).
Important Notes:
  1. When Node.js is installed Node and NPM become available globally. Means that you can create your site anywhere on your hard drive and with command prompt go to your directory like in Windows Command prompt.
  2. Similarly, you can now able to install any Node Package/Modules like Express Js, Mongoose, PM2, Nodemailer etc
  3. NPM – Node Package Manager – which lets you add all kinds of great stuff to Node quickly and easily.
For Example:
// Install Express Js
>> npm install express --save
You may also like - Node Js Interview Questions And Answers
Now, Create simple program using Node Js:
Create a test file (for example) C:\nodejs\test.js and 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, "");
console.log('Server running at');

Now, Open cmd (COMMAND PROMPT) and run following command:
>> cd C:\nodejs
>> node test.js
Open this address in your browser:
You may also like - Express Js Interview Questions
You may also like - React Js Interview Questions Answers
Full Stack Tutorials

Author | Blogger @FullStackTutorials | View all articles