Why is __dirname not defined in node REPL?

后端 未结 11 1455
傲寒
傲寒 2020-12-12 14:23

From the node manual I see that I can get the directory of a file with __dirname, but from the REPL this seems to be undefined. Is this a misunderstanding on my

11条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 15:23

    sometimes we make a file with .js extension and add consol.log(_dirname); but we face errors, we are in a hurry, so we forget to add one more underscore before the "dirname" so we face reference error.correct syntax is consol.log(__dirname);

提交回复
热议问题