# env-paths

> Get paths for storing things like data, config, cache, etc

Latest version **4.0.0** (published 2026-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install env-paths
pnpm add env-paths
yarn add env-paths
bun add env-paths
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-01-24 |
| First published | 2016-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 453 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | common, user, paths, env, environment, directory, dir, appdir, path, data, config, cache, logs, temp, linux, unix |

## Links

- npm: https://www.npmjs.com/package/env-paths
- Repository: https://github.com/sindresorhus/env-paths
- Homepage: https://github.com/sindresorhus/env-paths#readme
- Issues: https://github.com/sindresorhus/env-paths/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/env-paths

## Dependencies (1)

- [is-safe-filename](https://npm.io/package/is-safe-filename.md) ^0.1.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

- 4.0.0 (latest) — 2026-01-24
- 3.0.0 — 2021-08-27
- 2.2.1 — 2021-03-08
- 2.2.0 — 2019-04-01
- 2.1.0 — 2019-03-04
- 2.0.0 — 2018-11-05
- 1.0.0 — 2017-01-10
- 0.3.1 — 2016-10-18
- 0.3.0 — 2016-07-02
- 0.2.0 — 2016-06-24
- 0.1.0 — 2016-06-21

## README

# env-paths

> Get paths for storing things like data, config, cache, etc

Uses the correct OS-specific paths. Most developers get this wrong.

## Install

```sh
npm install env-paths
```

## Usage

```js
import envPaths from 'env-paths';

const paths = envPaths('MyApp');

paths.data;
//=> '/home/sindresorhus/.local/share/MyApp-nodejs'

paths.config
//=> '/home/sindresorhus/.config/MyApp-nodejs'
```

## API

### paths = envPaths(name, options?)

Note: It only generates the path strings. It doesn't create the directories for you. You can use [`fs.mkdir(…, {recursive: true})`](https://nodejs.org/api/fs.html#fspromisesmkdirpath-options) to create the directories.

#### name

Type: `string`

The name of your project. Used to generate the paths.

#### options

Type: `object`

##### suffix

Type: `string`\
Default: `'nodejs'`

**Don't use this option unless you really have to!**

Suffix appended to the project name to avoid name conflicts with native apps. Pass an empty string to disable it.

### paths.data

Directory for data files.

Example locations (with the default `nodejs` [suffix](#suffix)):

- macOS: `~/Library/Application Support/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\MyApp-nodejs\Data` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Data`)
- Linux: `~/.local/share/MyApp-nodejs` (or `$XDG_DATA_HOME/MyApp-nodejs`)

### paths.config

Directory for config files.

Example locations (with the default `nodejs` [suffix](#suffix)):

- macOS: `~/Library/Preferences/MyApp-nodejs`
- Windows: `%APPDATA%\MyApp-nodejs\Config` (for example, `C:\Users\USERNAME\AppData\Roaming\MyApp-nodejs\Config`)
- Linux: `~/.config/MyApp-nodejs` (or `$XDG_CONFIG_HOME/MyApp-nodejs`)

### paths.cache

Directory for non-essential data files.

Example locations (with the default `nodejs` [suffix](#suffix)):

- macOS: `~/Library/Caches/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\MyApp-nodejs\Cache` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Cache`)
- Linux: `~/.cache/MyApp-nodejs` (or `$XDG_CACHE_HOME/MyApp-nodejs`)

### paths.log

Directory for log files.

Example locations (with the default `nodejs` [suffix](#suffix)):

- macOS: `~/Library/Logs/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\MyApp-nodejs\Log` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Log`)
- Linux: `~/.local/state/MyApp-nodejs` (or `$XDG_STATE_HOME/MyApp-nodejs`)

### paths.temp

Directory for temporary files.

Example locations (with the default `nodejs` [suffix](#suffix)):

- macOS: `/var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\Temp\MyApp-nodejs` (for example, `C:\Users\USERNAME\AppData\Local\Temp\MyApp-nodejs`)
- Linux: `/tmp/USERNAME/MyApp-nodejs`

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