Need help with env-paths?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

sindresorhus
241 Stars 12 Forks MIT License 24 Commits 0 Opened issues

Description

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

Services available

!
?

Need anything else?

Contributors list

# 204
node
exec
test-fr...
nextjs
18 commits
# 7,443
TypeScr...
typescr...
iterm2
Node.js
2 commits
# 167,542
Shell
sw-prec...
ecmascr...
ESLint
1 commit
# 83,595
React
TypeScr...
1 commit
# 25,711
Nuxt.js
optimis...
node
npm
1 commit
# 6,407
chalk
Svelte
example...
Ada
1 commit

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

const envPaths = require('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

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.

paths.config

Directory for config files.

paths.cache

Directory for non-essential data files.

paths.log

Directory for log files.

paths.temp

Directory for temporary files.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.