What's the difference between
console.log(process.cwd())
and
console.log(__dirname);
I've seen both used in similar contexts.
process.cwd() returns the current working directory,
process.cwd()
i.e. the directory from which you invoked the node command.
node
__dirname returns the directory name of the directory containing the JavaScript source code file
__dirname
1.4m articles
1.4m replys
5 comments
57.0k users