helpermethod helpermethod - 1 year ago 143
Node.js Question

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

What's the difference between




I've seen both used in similar contexts.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download