1

I'm completely new to node.js. By reading the documentation and tutorials, I managed to download and install node.js on my windows.

How do I test it and make it work?

The file test.js is saved in the same directory as node.exe and contains:

console.log('Hello World');

Openning the command-line I typed:

$ node test.js

But nothing hapenns, just:

...
5
  • 1
    Did you use the node command-line or the general windows command-line? Commented Sep 19, 2013 at 10:10
  • 1
    I believe that is linux Commented Sep 19, 2013 at 10:10
  • @Sirko: node command-line Commented Sep 19, 2013 at 10:12
  • 1. You must be using Node.js command prompt. 2.Navigate to path having test.js using cd command 3. run node test.js. Commented Sep 19, 2013 at 10:14
  • 1
    @SmartLemon, I think windows since it is mentioned above "I managed to download and install node.js on my windows." Commented Sep 19, 2013 at 10:16

3 Answers 3

4

You are typing node test.js in the Node REPL not the command line. The ... is indicating that you haven't reached the end of a valid statement yet (because you are writing shell and not JavaScript).

Run a command line with your terminal emulator of choice (probably Windows Powershell if you are using Windows).

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

2 Comments

Using Windows Powershell I get "The term $ is not recognized ...". test.js in the same directory
$ is the representation of the command prompt, not something that you type yourself.
0

Run the Node REPL by executing node via the command-line without any arguments. The reason you're not getting the expected results is probably because you're running node.exe directly. Since you're using windows, start up CMD and run node.exe from there. Once you have the REPL running, try node test.js again, and this time it will work.

Comments

-1

![enter image description here][1]I have run it in nodejs shell and it is simply working

> console.log('Hello World');  
  Hello World  
  undefined  
>

Also I opened nodejs command prompt not default command prompt of windows and then

 node path_to_file 

it is working... same output

6 Comments

Yes, that also works for me. The problem is loading a js file from the command-line
yes please open node js command prompt and then try it not default command prompt of windows
what is your node version? is it installed properly?
I'm using v0.10.18. I've just downloaded and installed it from nodejs.org
where do you save your js file look at my uploaded picture I saved the js file in Desktop and then through command line I ran it by proper path
|

Your Answer

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