# appdirsjs

> OS-dependent application paths for cache, data and config directories

Latest version **1.2.8** (published 2026-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install appdirsjs
pnpm add appdirsjs
yarn add appdirsjs
bun add appdirsjs
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.2.8 |
| Published | 2026-07-28 |
| First published | 2020-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Maintainers | codingjerk |

## Links

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

## Recent versions

- 1.2.8 (latest) — 2026-07-28
- 1.2.7 — 2022-07-08
- 1.2.6 — 2021-10-21
- 1.2.5 — 2021-06-27
- 1.2.4 — 2020-11-23
- 1.2.3 — 2020-11-23
- 1.2.2 — 2020-11-23
- 1.2.1 — 2020-10-31
- 1.2.0 — 2020-10-31
- 1.1.0 — 2020-10-31
- 1.0.0 — 2020-10-24

## README

# appdirsjs

[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/codingjerk/appdirsjs/ci.yml)](https://github.com/codingjerk/appdirsjs/actions)
[![Codecov](https://img.shields.io/codecov/c/gh/codingjerk/appdirsjs)](https://codecov.io/gh/codingjerk/appdirsjs)
[![npm](https://img.shields.io/npm/v/appdirsjs)](https://www.npmjs.com/package/appdirsjs)
[![npm bundle size](https://img.shields.io/bundlephobia/min/appdirsjs)](https://www.npmjs.com/package/appdirsjs)
[![GitHub](https://img.shields.io/badge/license-MIT-blue)](https://github.com/codingjerk/appdirsjs/blob/master/_LICENSE.md)

A lightweight Node.js library providing standardized paths for directories to store configs, caches, and data files according to OS standards. On Linux, it follows the XDG Base Directory Specification. On macOS and Windows, it follows Apple and Microsoft guidelines.

## Installation

Using npm:

```sh
npm install appdirsjs
```

Or if you use Yarn:

```sh
yarn add appdirsjs
```

## Usage

```javascript
import appDirs from "appdirsjs";

const dirs = appDirs({ appName: "expo" });

// Display the OS-specific cache directory for temporary files
console.log("Cache Directory:", dirs.cache);
//   Linux:    /home/user/.cache/expo
//   macOS:    /Users/User/Library/Caches/expo
//   Windows:  C:\Users\User\AppData\Local\Temp\expo

// Display the OS-specific configuration directory for user settings
console.log("Config Directory:", dirs.config);
//   Linux:    /home/user/.config/expo
//   macOS:    /Users/User/Library/Preferences/expo
//   Windows:  C:\Users\User\AppData\Roaming\expo

// Display the OS-specific data directory for application data
console.log("Data Directory:", dirs.data);
//   Linux:    /home/user/.local/share/expo
//   macOS:    /Users/User/Library/Application Support/expo
//   Windows:  C:\Users\User\AppData\Local\expo
```

### Keep backward compatibility

When switching from an old-style dotfile directory,
such as `~/.myapp`, to a new one, like `~/.config/myapp`,
you can pass the `legacyPath` parameter
to keep using the old directory if it exists:

```javascript
import * as os from "os";
import * as path from "path";
import appDirs from "appdirsjs";

const dirs = appDirs({
  appName: "expo",
  // Use legacy directory if it exists
  legacyPath: path.join(os.homedir(), ".expo"),
});

console.log("Configuration Directory:", dirs.config);
// For instance, on Linux: /home/user/.expo
```

## TODO

- [ ] Android support
- [ ] XDG on BSD support
- [ ] CI tests on `bun` and `deno`
- [ ] Dev dependencies update
- [ ] README.md cleanup

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