I started setting up a node app but it prompt me this
syntax error near unexpected token `('
'/app.js: line 1: `var http = require("http");
this is my code for app.js
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 running at http://localhost:8080/');
can anyone help me in this
This is probably because you are running your script as if it is a bash script. You have two options
$ node your_pgm.js#!/path/to/node to the beginning of your program (it must be the very first line)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With