search

Home  >  Q&A  >  body text

node.js - console.log() reports errors when running with node

Created a app.js file with the following content:

var msg = 'Hello World'; 
console.log(msg);   

Run the file using node on the command line, and the error will be as follows:

Usedvs code, the debugging interface outputs normally.

I have been using webstorm before, and it seems that there will be no such problem.

習慣沉默習慣沉默2728 days ago757

reply all(2)I'll reply

  • 阿神

    阿神2017-06-05 11:15:18

    Is this what you said?

    This error is that there is no app.js file in your app directory

    reply
    0
  • 天蓬老师

    天蓬老师2017-06-05 11:15:18

    When opening the command line tool, do not enter the node environment, switch directly to the directory and enter node app.js. Don’t enter node first

    reply
    0
  • Cancelreply