Get paths for storing things like data, config, cache, etc
npm install env-paths> Get paths for storing things like data, config, cache, etc
Uses the correct OS-specific paths. Most developers get this wrong.
``sh`
npm install env-paths
`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'
`
Note: It only generates the path strings. It doesn't create the directories for you. You can use fs.mkdir(…, {recursive: true}) to create the directories.
#### name
Type: string
The name of your project. Used to generate the paths.
#### options
Type: object
##### suffix
Type: string\'nodejs'
Default:
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.
Directory for data files.
Example locations (with the default nodejs suffix):
- macOS: ~/Library/Application Support/MyApp-nodejs%LOCALAPPDATA%\MyApp-nodejs\Data
- Windows: (for example, C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Data)~/.local/share/MyApp-nodejs
- Linux: (or $XDG_DATA_HOME/MyApp-nodejs)
Directory for config files.
Example locations (with the default nodejs suffix):
- macOS: ~/Library/Preferences/MyApp-nodejs%APPDATA%\MyApp-nodejs\Config
- Windows: (for example, C:\Users\USERNAME\AppData\Roaming\MyApp-nodejs\Config)~/.config/MyApp-nodejs
- Linux: (or $XDG_CONFIG_HOME/MyApp-nodejs)
Directory for non-essential data files.
Example locations (with the default nodejs suffix):
- macOS: ~/Library/Caches/MyApp-nodejs%LOCALAPPDATA%\MyApp-nodejs\Cache
- Windows: (for example, C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Cache)~/.cache/MyApp-nodejs
- Linux: (or $XDG_CACHE_HOME/MyApp-nodejs)
Directory for log files.
Example locations (with the default nodejs suffix):
- macOS: ~/Library/Logs/MyApp-nodejs%LOCALAPPDATA%\MyApp-nodejs\Log
- Windows: (for example, C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Log)~/.local/state/MyApp-nodejs
- Linux: (or $XDG_STATE_HOME/MyApp-nodejs)
Directory for temporary files.
Example locations (with the default nodejs suffix):
- macOS: /var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-nodejs%LOCALAPPDATA%\Temp\MyApp-nodejs
- Windows: (for example, C:\Users\USERNAME\AppData\Local\Temp\MyApp-nodejs)/tmp/USERNAME/MyApp-nodejs`
- Linux: