Node REPL throws SyntaxError: Unexpected identifier

前端 未结 2 865
感动是毒
感动是毒 2021-01-20 02:57

I am very newbie to node.js. In the node REPL everything was working fine. But something changed. When I try to execute a file it shows this...

D:\\Projects-         


        
相关标签:
2条回答
  • 2021-01-20 03:05

    Are you running node by double clicking on it?

    You have to run node from command line and give command node xyz.js on command line.

    node should be in your class path or while executing node use full path. such as c:\work\nodetest\node .\xyz.js

    in above i coped the js file in same folder as node file.

    0 讨论(0)
  • 2021-01-20 03:30

    You can't call the node executable from within the node REPL... Only JavaScript statements/expressions.

    Try require('./module.js')

    0 讨论(0)
提交回复
热议问题