Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
xdgAppPaths
✓ import xdgAppPaths from 'xdg-app-paths'
✗ import { xdgAppPaths } from 'xdg-app-paths'
Default import. Named import does not exist.
xdgAppPaths
✓ const xdgAppPaths = require('xdg-app-paths/cjs')
✗ const xdgAppPaths = require('xdg-app-paths')
CommonJS users must require from 'xdg-app-paths/cjs', not the main entry.
xdgAppPaths
✓ import xdgAppPaths from 'https://deno.land/x/xdg_app_paths@v8.3.0/src/mod.deno.ts'
✗ import xdgAppPaths from 'xdg-app-paths'
Deno requires the full URL to the Deno-specific module.
Demonstrates all major XDG path retrieval methods with cross-platform examples.
import xdgAppPaths from 'xdg-app-paths';
// Get XDG directories for the application named 'myapp'
const cacheDir = xdgAppPaths.cache();
console.log('Cache directory:', cacheDir);
// Linux: /home/user/.cache/myapp
// macOS: /Users/user/Library/Caches/myapp
// Windows: C:\Users\user\AppData\Local\myapp\Cache
const configDir = xdgAppPaths.config();
console.log('Config directory:', configDir);
// Linux: /home/user/.config/myapp
// macOS: /Users/user/Library/Application Support/myapp
// Windows: C:\Users\user\AppData\Roaming\myapp\Config
const dataDir = xdgAppPaths.data();
console.log('Data directory:', dataDir);
// Linux: /home/user/.local/share/myapp
// macOS: /Users/user/Library/Application Support/myapp
// Windows: C:\Users\user\AppData\Roaming\myapp\Data
const configDirs = xdgAppPaths.configDirs();
console.log('Config directories (priority order):', configDirs);
// Linux: ['/home/user/.config/myapp', '/etc/xdg/myapp']
// macOS: ['/Users/user/Library/Application Support/myapp', '/Library/Application Support/myapp']
// Windows: ['C:\Users\user\AppData\Roaming\myapp\Config']
const runtimeDir = xdgAppPaths.runtime();
console.log('Runtime directory:', runtimeDir);
// Linux: /run/user/1000/myapp
// macOS: null (not supported)
// Windows: null (not supported)
const stateDir = xdgAppPaths.state();
console.log('State directory:', stateDir);
// Linux: /home/user/.local/state/myapp
// macOS: /Users/user/Library/State/myapp
// Windows: C:\Users\user\AppData\Local\myapp\State
Errors
Common errors & fixes
Cannot find module 'xdg-app-paths'
CommonJS code using require('xdg-app-paths') instead of require('xdg-app-paths/cjs')
fixChange to const xdgAppPaths = require('xdg-app-paths/cjs'); TypeError: xdgAppPaths is not a constructor
Attempting to instantiate the default export with 'new xdgAppPaths()'
fixUse 'xdgAppPaths.cache()' etc. directly, no instantiation needed.
SyntaxError: The requested module 'xdg-app-paths' does not provide an export named 'xdgAppPaths'
Using named import { xdgAppPaths } from 'xdg-app-paths' instead of default import
fixUse 'import xdgAppPaths from 'xdg-app-paths'' (default import).
Audit
Dependencies
No dependency data recorded yet.