Hans
Hans

Reputation: 151

Node js 'console' error in cmd

I want to use the node.js on the windows. so I install node but I can't execute a .js file. That is my source code. And I atteched the error screen.

helloworld.js

console.log("Hello, World!")

enter image description here

Upvotes: 1

Views: 1501

Answers (1)

user3
user3

Reputation: 740

This error is happening because your script is not executed with nodejs but with Microsoft jscript.

The command you wrote "node node.js" is executing the file ode.js instead of the nodejs in your system in the same way you can execute cmd by typing cmd instead of cmd.exe.

To fix that you need to do one of those :

  • rename the file to something other than node
  • move the file named node in a subfolder (i.e. src/node.js)
  • associate .js file with nodejs instead of microsoft jscript

Upvotes: 3

Related Questions