Why is __dirname not defined in node REPL?

后端 未结 11 1456
傲寒
傲寒 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:11

    Though its not the solution to this problem I would like to add it as it may help others.

    You should have two underscores before dirname, not one underscore (__dirname not _dirname).

    NodeJS Docs

提交回复
热议问题