process.cwd()
Returns the current working directory of the Node process.
Syntax
process.cwd() Returns
string — The absolute path of the working directory.
Examples
console.log(process.cwd());
Output
/home/user/project
import { join } from 'node:path';
const configPath = join(process.cwd(), 'config.json');
console.log(configPath);
Output
/home/user/project/config.json
Notes
This is where the user ran `node`, not where the script file lives.
For paths relative to the module use `import.meta.dirname`. Change it
with `process.chdir()`, though that is rarely advisable.