os.homedir()
Returns the current user home directory.
Syntax
os.homedir() Returns
string — The absolute path to the home directory.
Examples
import { homedir } from 'node:os';
console.log(homedir());
Output
/Users/ada
import { homedir } from 'node:os';
import { join } from 'node:path';
const configFile = join(homedir(), '.myapprc');
console.log(configFile);
Output
/Users/ada/.myapprc
Notes
Prefer this over reading `process.env.HOME`/`USERPROFILE` directly,
as it handles platform differences. Combine with `path.join` to
build per-user config paths for CLI tools.