Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
The env-paths npm package is used to generate paths for storing things like data, config, cache, etc., in a way that complies with the operating system's conventions. It is useful for developers who want to ensure their applications follow the best practices for file storage locations on different platforms.
Config Paths
Generates paths for storing configuration files. The 'config' property will provide a path that is suitable for the user's operating system.
{"config": require('env-paths')('MyApp').config}
Data Paths
Generates paths for storing data files. The 'data' property will give a path that is appropriate for the user's operating system.
{"data": require('env-paths')('MyApp').data}
Cache Paths
Generates paths for storing cache files. The 'cache' property will provide a path that is suitable for the user's operating system.
{"cache": require('env-paths')('MyApp').cache}
Log Paths
Generates paths for storing log files. The 'log' property will give a path that is appropriate for the user's operating system.
{"log": require('env-paths')('MyApp').log}
Temporary Paths
Generates paths for storing temporary files. The 'temp' property will provide a path that is suitable for the user's operating system.
{"temp": require('env-paths')('MyApp').temp}
Similar 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.
Get paths for storing things like data, config, cache, etc
$ npm install --save env-paths
const envPaths = require('env-paths');
const paths = envPaths('MyApp');
paths.data;
//=> '/home/sindresorhus/.local/share/MyApp-nodejs'
paths.config
//=> '/home/sindresorhus/.config/MyApp-nodejs'
Type: string
Name of your project. Used to generate the paths.
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.
Directory for config files.
Directory for non-essential data files.
Directory for log files.
Directory for temporary files.
MIT © Sindre Sorhus
FAQs
Get paths for storing things like data, config, cache, etc
The npm package env-paths receives a total of 15,525,415 weekly downloads. As such, env-paths popularity was classified as popular.
We found that env-paths demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.