-1

I'm currently in the process of learning Node via "Learnyounode". However, when testing some javascript files on my computer, anytime I try to run even a simple "Hello World"

console.log("Hello World");

It gives me an error returning

Error: 'console' is undefined.

Is this a problem with my Command prompt or an error on my system? do I need to re-install sometime for Javascript? my code works fine in my Browser console, but not in my local Command lines.

Any help would appreciated, Thanks in advance!

Gwinert
  • 67
  • 1
  • 7
  • Take a look at the following post, which may explain the result you are seeing: http://stackoverflow.com/questions/8457389/node-js-displays-undefined-on-the-console – David Tansey Jan 26 '17 at 20:07
  • Here's your problem: http://osric.com/chris/accidental-developer/2016/06/node-js-error-console-is-undefined/ – Adam Jenkins Jan 26 '17 at 20:08
  • Remember to mark an answer as accepted if it solved your problem :) [How does accepting an answer work?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – Matt Mokary Jan 26 '17 at 20:14

1 Answers1

1

I know starting with NodeJS can be difficult... Try the follwing:

1. Create a .js file... call it test.js
2. In the file write command:

    console.log('hello world from node');

3. save the file.
4. Navigate to that directory and type:

    node test.js

Now you will see the output.

Good Luck!

spooky
  • 1,620
  • 1
  • 13
  • 15
  • Thank you! It was because I wasn't leading it with node. The output worked, and now I'm off to learning! – Gwinert Jan 26 '17 at 20:11