el_kraken el_kraken - 7 months ago 32
Node.js Question

Need help getting simple node.js express to run

I'm trying a simple sample of node express that I copied from online. The script is below which I think is pretty standard.

var http = require('http');

http.createServer(function(request, response)){

console.log('listening on port 8080...');

I used the bash on ubuntu on windows command as follows:

npm init

node SampleServer.js (the name of my file)

When I do this, I expect some response from the command line. But when I enter the "node SamplerServer.js" command, nothing happens. When I direct the browser to port 8080, I get an error message as well.

I'm using nodeclipse and the installing that on my machine was pretty complicated. Prior to any of the steps above, I created an express project in eclipse ide. It seems to perform a lot of pre steps but in the end, I think I'm getting some of the error messages below. I'm mentioning this because I'm thinking perhaps I installed one of the modules wrong.

enter image description here


Start with simple stuff...

Use express-generator to create simple app by the following command

1-> npm install -g express-generator with root or Admin access

2-> Run express demoapp.

3-> Navigate to demoapp

4-> Do npm install

5-> Run from command with npm start: it run by default on http://localhost:3000

Hit that URL from Browser