process.cwd()和__dirname有什么区别? [英] What's the difference between process.cwd() vs __dirname?
本文介绍了process.cwd()和__dirname有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
两者之间有什么区别
console.log(process.cwd())
和
console.log(__dirname);
我已经看到两者都用在相似的上下文中.
I've seen both used in similar contexts.
推荐答案
即您从中调用node
命令的目录.
i.e. the directory from which you invoked the node
command.
__dirname
返回包含以下内容的目录的目录名称: JavaScript源代码文件
__dirname
returns the directory name of the directory containing the JavaScript source code file
这篇关于process.cwd()和__dirname有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文