Arc
Arc

Reputation: 1700

Hello world in Node.js

I am trying to start off with node.js. Just wrote

console.log("Hello World");

in a HelloWorld.js file and tried to run

node HelloWorld.js on the terminal. I see the following error:

/Users/arkidmitra/Desktop/NodeJs/helloworld.js:1
��c
^

node.js:134
    throw e; // process.nextTick error, or 'error' event on first tick
    ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:399:25)
    at Object..js (module.js:410:10)
    at Module.load (module.js:336:31)
    at Function._load (module.js:297:12)
    at Array.<anonymous> (module.js:423:10)
    at EventEmitter._tickCallback (node.js:126:26)

I wrote it in simple textedit. I can see some special characters in the file. What is the possible problem and how do I resolve it?

Upvotes: 2

Views: 901

Answers (2)

McKayla
McKayla

Reputation: 6949

I'd try using a different editor.

I quite like Kod, even though it's a bit buggy.

If you want something more stable, Komodo Edit should be good.

Also, you should delete and rewrite (not copy and paste) the file, to get rid of the unwanted characters.

Upvotes: 2

YXD
YXD

Reputation: 32521

Delete the file and write it again with a different text editor...

Upvotes: 1

Related Questions