Report this

What is the reason for this report?

"syntax error near unexpected token `('" in node js for http

Posted on March 12, 2019

I started setting up my first node app but it prompt me this

./app.js: line 1: syntax error near unexpected token `('
'/app.js: line 1: `var http = require("http");

my code is

var http = require("http");
http.createServer(function (req,res){
	res.writeHead(200, {'content-Type': 'text/plain'});
	res.end('Hello World\n');
}).listen(8080, 'localhost');
console.log("server runnig at 8080");

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.