0

I have Node JS installed on my system, how can i configure local server using node js without wamp or xampp so that i can run my applications in my local machine? can somebody help me with the step by step procedure?

1
  • Your get or write a small node.js app that runs a web server (takes about 10 lines of code) and then you start that app. node.js is NOT a web server itself. It can run apps that are web servers once you have such an app. Express is a node.js framework that makes web servers pretty easy. Here's a simple example web server in Express: expressjs.com/en/starter/hello-world.html Commented Mar 17, 2016 at 6:25

2 Answers 2

1

Node JS makes it really simple to create a server. All you need to do is write a file : server.js.

var http = require("http");
var server = http.createServer(function(request, response) {
  response.end('Hello World!');
});

server.listen(8000);
console.log("Server is listening");

Open cmd and write

node server.js

Go to your browser and open

localhost:8000

That should work!

Sign up to request clarification or add additional context in comments.

Comments

0

Try this one for configure local server without wamp || Xampp

var http = require('http'); // 1 - Import Node.js core module

var server = http.createServer(function (req, res) {   // 2 - creating server

    // handle incoming requests here..

});

server.listen(5000); //3 - listen for any incoming requests

console.log('Node.js web server at port 5000 is running..')

1 Comment

Please format your code by prepending with four spaces, or select the code and click the {} button in the edit page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.