chaitanya.varanasi
chaitanya.varanasi

Reputation: 956

Node.js Program Error (Module.js)

Hey Guys I have been testing the water with node.js and I wrote a simple web-server program by Ryan Dahl.

//web-server.js
var http= require('http');
http.createServer(function(req,res){
   res.writeHead(200, {'content-type':'text/plain'});
   res.end("helo world \n");
});

s.listen(8000);

Weirdly, I get this error

enter image description here

As you can see, the first command is node-webserver.js The second command is where the error is displayed

I do know however that node.js is not broken because the basic introductory program provided on the node.js still works as it is supposed to. Sorry for the massive error screenshot!

Thanks for any help!

Upvotes: 1

Views: 179

Answers (2)

raina77ow
raina77ow

Reputation: 106463

This is the time when error message actually means something: {\rtf1\ansi\ansi is not a valid JavaScript code. And this is the line which was inserted by your text editor.

And, please, please, please, don't EVER use WordPad for editing code. There's plenty of good and free text editors/IDE around here: I personally use Geany for little tasks, and NetBeans for big projects. I suppose you might try Visual Studio Express, too (it's free, unlike its bigger brothers). And there's also such a nice thing as Notepad++.

But using WordPad for writing code is just like using a chainsaw to nail a shelf, in my opinion.

Upvotes: 1

lanzz
lanzz

Reputation: 43198

Your file is apparently saved as a RTF file, while it needs to be saved as plain text.

Upvotes: 1

Related Questions