# user-home

> Get the path to the user home directory

Latest version **3.0.0** (published 2021-04-09) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install user-home
pnpm add user-home
yarn add user-home
bun add user-home
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-04-09 |
| First published | 2014-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/user-home) |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 158 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | user, home, homedir, os-homedir, dir, directory, folder, path, env, vars, environment, variables, userprofile |

## Links

- npm: https://www.npmjs.com/package/user-home
- Repository: https://github.com/sindresorhus/user-home
- Homepage: https://github.com/sindresorhus/user-home#readme
- Issues: https://github.com/sindresorhus/user-home/issues
- npm.io page: https://npm.io/package/user-home

## Dependencies (1)

- [os-homedir](https://npm.io/package/os-homedir.md) ^1.0.0

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2021-04-09
- 2.0.0 — 2015-06-13
- 1.1.1 — 2015-01-13
- 1.1.0 — 2014-10-16
- 1.0.0 — 2014-08-03

## README

Deprecated. Just use `import {homedir} from 'os';`.

---

# user-home

> Get the path to the user home directory


## Install

```
$ npm install user-home
```


## Usage

```js
const userHome = require('user-home');

console.log(userHome);
//=> '/Users/sindresorhus'
```

Returns `null` in the unlikely scenario that the home directory can't be found.


## FAQ

### Why not just use the `os-home` module?

This module was made long before [`os-homedir`](https://github.com/sindresorhus/os-homedir). When Node.js decided to add a native method for getting the user's home directory, I made a polyfill matching its API and decided to depend on it here, so not to have duplicate code. The main reason this one is still around is that lots of modules depend on it and I see no reason to inconvenience dependents by deprecating this. This one also gets the home directory on startup and returns a string rather than exposing a method, so it's faster, and I prefer this API. [Modules are cheap in Node.js](https://github.com/sindresorhus/ama/issues/10#issuecomment-117766328), so doesn't matter. Use whichever you prefer. I'm going to continue using this one.


## Related

- [user-home-cli](https://github.com/sindresorhus/user-home-cli) - CLI for this module
- [home-or-tmp](https://github.com/sindresorhus/home-or-tmp) - Get the user home directory with fallback to the system temp directory


---

<div align="center">
	<b>
		<a href="https://tidelift.com/subscription/pkg/npm-user-home?utm_source=npm-user-home&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
	</b>
	<br>
	<sub>
		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
	</sub>
</div>

---
_Source: https://npm.io/package/user-home · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
