
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
Get paths for storing things like data, config, cache, etc
Uses the correct OS-specific paths. Most developers get this wrong.
npm install env-paths
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.
Type: string
The name of your project. Used to generate the paths.
Type: object
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.
Directory for data files.
Example locations (with the default nodejs suffix):
~/Library/Application Support/MyApp-nodejs%LOCALAPPDATA%\MyApp-nodejs\Data (for example, C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Data)~/.local/share/MyApp-nodejs (or $XDG_DATA_HOME/MyApp-nodejs)Directory for config files.
Example locations (with the default nodejs suffix):
~/Library/Preferences/MyApp-nodejs%APPDATA%\MyApp-nodejs\Config (for example, C:\Users\USERNAME\AppData\Roaming\MyApp-nodejs\Config)~/.config/MyApp-nodejs (or $XDG_CONFIG_HOME/MyApp-nodejs)Directory for non-essential data files.
Example locations (with the default nodejs suffix):
~/Library/Caches/MyApp-nodejs%LOCALAPPDATA%\MyApp-nodejs\Cache (for example, C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Cache)~/.cache/MyApp-nodejs (or $XDG_CACHE_HOME/MyApp-nodejs)Directory for log files.
Example locations (with the default nodejs suffix):
~/Library/Logs/MyApp-nodejs%LOCALAPPDATA%\MyApp-nodejs\Log (for example, C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Log)~/.local/state/MyApp-nodejs (or $XDG_STATE_HOME/MyApp-nodejs)Directory for temporary files.
Example locations (with the default nodejs suffix):
/var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-nodejs%LOCALAPPDATA%\Temp\MyApp-nodejs (for example, C:\Users\USERNAME\AppData\Local\Temp\MyApp-nodejs)/tmp/USERNAME/MyApp-nodejsSimilar to env-paths, appdata-path is used to find the path to the user's app data directory. It is more focused on this single use case and does not provide the variety of paths that env-paths does.
osenv is another package that provides a way to get environment settings like paths for temporary files and user's home directory. It is similar to env-paths but has a broader scope, including network settings and shell paths.
userhome is a simple package to get the path to the user's home directory. It is much more limited in scope compared to env-paths, which provides paths for various types of application files.
FAQs
Get paths for storing things like data, config, cache, etc
The npm package env-paths receives a total of 41,941,585 weekly downloads. As such, env-paths popularity was classified as popular.
We found that env-paths demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.