Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting a node.js server

Tags:

I recently got into node and I installed it on my localhost. I am using WAMP. I am on Windows Vista.

Anwyay, I installed it. I made a new file in my localhost directory with this being called server.js

var http = require('http');  http.createServer(function (request, response) {     response.writeHead(200, {         'Content-Type': 'text/plain',         'Access-Control-Allow-Origin' : '*'     });     response.end('Hello World\n'); }).listen(1337); 

then I went to node and tried typing % node server.js and all I got was an ellipses. What gives?


UPDATE: I checked my Systems variable and saw that my PATH lists the node.js as C:\Program Files (x86)\nodejs\

enter image description here

like image 406
test Avatar asked May 14 '12 05:05

test


1 Answers

Run cmd and then run node server.js. In your example, you are trying to use the REPL to run your command, which is not going to work. The ellipsis is node.js expecting more tokens before closing the current scope (you can type code in and run it on the fly here)

like image 187
dwerner Avatar answered Sep 19 '22 14:09

dwerner