Linas
Linas

Reputation: 4408

Node.js Hello World not working

I'm trying to get my node.js Hello World code to work. My problem is that when I try to run my "Hello World" js script file on my node console, I get "..." and it keeps repeating this until I run .clear command.

But when I type my hello code directly into console, everything works just fine... I'm using Windows 7 x64.

Here is a screenshot of the result:

https://i.sstatic.net/SJqaQ.png

enter image description here

Upvotes: 0

Views: 29544

Answers (4)

user2892750
user2892750

Reputation: 1

Now you just go to [Start > All Programs > Node.js > Node.js command prompt] and then run from there.

Upvotes: -2

Rami Jarrar
Rami Jarrar

Reputation: 4643

from cmd.exe change directory to the script directory, then hit:

node hello.js

then from the web browser go to :

http://127.0.0.1:8000/

you'll see the hello world message :)

Upvotes: 2

EhevuTov
EhevuTov

Reputation: 20463

  1. click "Start"
  2. run cmd.exe

then run the following commands from the command line:

cd c:\Users\Shhinigami\Desktop\

node hello.js

When you run node.exe by itself, it opens up the node interface. When you run it with an argument, such as a filename, it tries to execute the file you pass as the argument. Also, run:

node -h

Upvotes: 2

Emil Stenström
Emil Stenström

Reputation: 14126

You are trying to run your program inside node itself. The console you are starting your program from, is for raw javascript code. The line you wrote there is meant to be run in the windows terminal. Try the same command there and it'll work.

Upvotes: 15

Related Questions