javascript - node js not working with SyntaxError: Unexpected identifier -


so, started learning node.js , tried basic thing in world: "hello world" server.

the code following (copied actual book):

var http = require("http"); http.createserver(function(request, response) {     response.writehead(200, {"content-type": "text/plain"});     response.write("hello world");     response.end(); }).listen(8888); 

i hit node.js executable, type node server.js , gives famous syntaxerror: unexpected identifier.

tried looking similar questions couldn't find something simple i'm trying accomplish.

the node repl aka node shell, repl provides way interactively run javascript , see results. can used debugging, testing, or trying things out. here 1 how-to-use-nodejs-repl

whereas, command line used run node command node server.js.

you run node server.js in command line.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -