Small library to retrieve OS-specific paths for storing data, config, cache, logs, and temp files. Version 4.0.0 requires Node >=20, ships TypeScript definitions, and is ESM-only. Correctly implements XDG Base Directory (Linux), macOS conventions, and Windows %APPDATA%/%LOCALAPPDATA%. Unlike ad-hoc path joining, env-paths avoids common portability mistakes. Published by Sindre Sorhus; stable API with infrequent updates.
npm install env-pathsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import envPaths, generate paths for 'MyApp', and create those directories (the library does not create them).
Use dynamic import() or migrate to ESM. If using TypeScript, set module to 'ESNext' or 'NodeNext'.
Upgrade Node.js to v20 or later.
After obtaining paths, use fs.mkdirSync(path, { recursive: true }) or the promise-based equivalent.Call envPaths('AppName', { suffix: '' }) for paths without suffix.Switch to ESM imports and update Node to >=20.
Replace require('env-paths') with import envPaths from 'env-paths'.Call mkdirSync(paths.data, { recursive: true }) before writing files.Use import envPaths from 'env-paths'.
No dependency data recorded yet.