A
A
A person from Kazakhstan2017-05-28 14:51:34
JavaScript
A person from Kazakhstan, 2017-05-28 14:51:34

How to run server on node?

I did exactly as it says here , I also did node.jsnpm install node-static after installation , created server.js and wrote into it:

var http = require('http');
var static = require('node-static');
var file = new static.Server('.');

http.createServer(function(req, res) {
  file.serve(req, res);
}).listen(3000);

console.log('Server running on port 3000')

I start the server node url ... server.js and in cmd it is written that
server running port 3000
screenshot
ecce54b13dcc4f478dc9437faf0730b2.png

but when called in the address bar 127.0.0.1:3000 gives an error
screenshot
db8628f3b2cd42e2bbdc0658e7d41a3d.png

what am I doing wrong ?
decided on my own

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Person from Kazakhstan, 2017-05-28
@LenovoId

Solution 1 => https://www.youtube.com/watch?v=oa9m8321_nw
Solution 2 => https://www.youtube.com/watch?v=2nutwYB9AXg&t=122s
in case someone needs it

A
Anton Ulanov, 2017-05-28
@antonsr98

firewall?

A
Alexeytur, 2017-05-28
@Alexeytur

On learn.javascript.ru it is written to check like this:
3. Open 127.0.0.1:8080/server.js in the browser.
Should output the server.js file code.
You need to put some file in the current folder and add it to the path in the browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question