0

If I type console.log('Hello World'); in node.js it works, I get the "Hello World" message back.

But if I make a "helloworld.js" document with console.log('Hello World'); inside and then type "node helloworld.js" in node then nothing happens.

I have tried placing the script in same folder as node.js but still doesn't work.

1
  • Do you get any output at all? What OS are you using? How is Node installed? Commented May 5, 2013 at 18:14

1 Answer 1

1

Make sure that you're not running Nodejs.exe because that is the REPL.

Instead you should open a regular Command Prompt window (cmd.exe) and run the command

node helloworld.js

Make sure you run this command in the directory where the js file exists, the node application path is mapped in your environment settings.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I was doing it in nodejs.exe :) A side question I need answer to to be able to start the script still.. How do i navigate in cmd? The only command I know of is "cd.." I have no idea to navigate to the directory the script is in. I never really had to use cmd until now.
@Krymmt The easiest way would be to create a folder for example in your C drive root C:\nodeApp then you would enter in command prompt : cd C:\nodeApp enter , then node helloworld.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.