Node.js – Error ‘console’ is undefined

I just installed Node.js on a new system and wanted to make sure it worked. I tested it with a simple hello world script.

Contents of the node.js file
console.log("Hello node");

Then I attempted to run it:
C:\>node node.js

Which produced the following error:
Script: C:\node.js
Line: 1
Char: 1
Error: 'console' is undefined
Code: 800A1391
Source: Microsoft JScript runtime error

Weird. And Microsoft JScript runtime? Very weird.

Turns out, Windows is trying to run the Javascript, node.js, not via Node.js but natively in Windows.

If I rename the file hellonode.js I can reproduce the same error:
C:\>hellonode

Or I can run the intended file via Node.js:
C:\>node hellonode.js
Hello node

I did not realize that the Windows command prompt could/would execute Javascript files natively.