Home

Awesome

env-paths

Get paths for storing things like data, config, cache, etc

Uses the correct OS-specific paths. Most developers get this wrong.

Install

$ npm install env-paths

Usage

import envPaths from 'env-paths';

const paths = envPaths('MyApp');

paths.data;
//=> '/home/sindresorhus/.local/share/MyApp-nodejs'

paths.config
//=> '/home/sindresorhus/.config/MyApp-nodejs'

API

paths = envPaths(name, options?)

Note: It only generates the path strings. It doesn't create the directories for you. You could use make-dir to create the directories.

name

Type: string

The name of your project. Used to generate the paths.

options

Type: object

suffix

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.

paths.data

Directory for data files.

Example locations (with the default nodejs suffix):

paths.config

Directory for config files.

Example locations (with the default nodejs suffix):

paths.cache

Directory for non-essential data files.

Example locations (with the default nodejs suffix):

paths.log

Directory for log files.

Example locations (with the default nodejs suffix):

paths.temp

Directory for temporary files.

Example locations (with the default nodejs suffix):


<div align="center"> <b> <a href="https://tidelift.com/subscription/pkg/npm-env-paths?utm_source=npm-env-paths&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> </b> <br> <sub> Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. </sub> </div>