The problem was that you opened the Node.js repl while everyone automatically assumed you were in the command prompt. For what it's worth you can run a javascript file from the repl with the .load
command. For example:
.load c:/users/username/documents/script.js
The same command can also be used in the command prompt if you first start node inside the command prompt by entering node
with no arguments (assuming node is in PATH).
I find it fascinating that 1)everyone assumed you were in the command prompt rather than repl, 2)no one seems to know about .load
, and 3)this has 273 upvotes, proving that a lot of other node.js beginners are similarly confused.