Back to Developer Roadmap

Process Cwd Vs Dirname

src/data/question-groups/nodejs/content/process-cwd-vs-dirname.md

4.0283 B
Original Source

process.cwd() returns the current working directory of the Node.js process, while __dirname returns the directory name of the current module.

js
console.log(process.cwd());
// /Users/username/projects/nodejs

console.log(__dirname);
// /Users/username/projects/nodejs/src