NodeJs file path

In Node.js:

__dirname Always point to the absolute path is executed js file, so when you  /d1/d2/myscript.js write a file  __dirname, its value is  /d1/d2 . (Note: It is two underscores)

./ You will return to the path of the command execution node, for example, your job path.

只有在 require() Used  ./ when, then the path will be contained  require() relative path to the script file, nothing to do with your working directory.

Guess you like

Origin www.cnblogs.com/kongwei/p/11362374.html