You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight Node.js library providing standardized paths for directories to store configs, caches, and data files according to OS standards. On Linux it's following XDG Base Directory Specification. On MacOS and Windows it's following Apple and Microsoft guidelines.
Installation
Using npm:
npm install appdirsjs
Or if you use Yarn:
yarn install appdirsjs
Usage
importappDirsfrom"appdirsjs";constdirs=appDirs({appName: "expo"});// Display the OS-specific cache directory for temporary filesconsole.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 settingsconsole.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 dataconsole.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
Then switching from old-style dotfile directory,
such as ~/.myapp to new, like ~/.config/myapp,
you can pass legacyPath parameter
to keep using old directory if it exists:
import*asosfrom"os";import*aspathfrom"path";importappDirsfrom"appdirsjs";constdirs=appDirs({appName: "expo",// Use legacy directory if it existslegacyPath: 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
About
A node.js library to get paths to directories to store configs, caches and data according to OS standarts.