What's the difference between process.cwd() vs __dirname?

后端 未结 4 648
谎友^
谎友^ 2020-11-29 14:54

What\'s the difference between

console.log(process.cwd())

and

console.log(__dirname);

I\'ve seen both use

4条回答
  •  天命终不由人
    2020-11-29 15:44

    process.cwd() returns the current working directory,

    i.e. the directory from which you invoked the node command.

    __dirname returns the directory name of the directory containing the JavaScript source code file

提交回复
热议问题