1

This is a completely newbie question and I'm sure the solution is very easy but I don't get it.

I downloaded Node.js and put the command-tool file and the npm in my project file.

I created a file called example.js which contains

console.log("hello world"); 

Now I open the node file and type in

node example.js 

And it shows me unexpected Identifier.

Thanks in advance.

Edit:

 node -v 

Shows node is not defined ?? .. I'm slightly confused.

Edit2: MAC IOS

Edit3: I installed it and the path was usr/local/bin am I allowed to just move the file?

Edit4: Thanks node -v works now. I opened it through the cmd tool

Edit5: okay now everything works.. I thought I have to work with the node cmd tool. Thanks for the quick help!

6
  • 1
    Can you show the full error message? Also what does node -v say? And which operating system do you have? Commented Jun 1, 2015 at 9:58
  • You either do not have Node.js installed, or your OS is not finding it. Commented Jun 1, 2015 at 10:00
  • As I'm reading your question it seem like you added node example.js in a file (which is why you get unexpected indentifier), node example.js should be typed in your shell. Open a terminal and issue that command from the directory in which you have the file. Commented Jun 1, 2015 at 10:02
  • I think you have to be somwhat more specific? If you open the node file and type node example.js you would get an unexpected identifier error as it's not valid javascript, you have to open a command line window and type node example.js ? Commented Jun 1, 2015 at 10:02
  • Open new terminal ( run-> cmd ) and then try "node /example.js" Commented Jun 1, 2015 at 10:04

1 Answer 1

1
  1. Open terminal
  2. Go to the folder you have your example.js (use cd-command)
  3. type in terminal node example.js, press enter

You should not RUN node before typing node example.js

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.