{"id":46827,"library":"xdg-app-paths","title":"xdg-app-paths","description":"Determine XDG-compatible paths for storing application files (cache, config, data, etc) on Linux, macOS, and Windows. Version 8.3.0 supports CJS, ESM, TypeScript, and Deno. Actively maintained with regular releases. Unlike similar libraries, it automatically derives application name from the calling module's filename and provides a separate CJS entry point.","status":"active","version":"8.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/rivy/js.xdg-app-paths","tags":["javascript","appdir","application","cache","common","config","cross-platform","data","directory","typescript"],"install":[{"cmd":"npm install xdg-app-paths","lang":"bash","label":"npm"},{"cmd":"yarn add xdg-app-paths","lang":"bash","label":"yarn"},{"cmd":"pnpm add xdg-app-paths","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import. Named import does not exist.","wrong":"import { xdgAppPaths } from 'xdg-app-paths'","symbol":"xdgAppPaths","correct":"import xdgAppPaths from 'xdg-app-paths'"},{"note":"CommonJS users must require from 'xdg-app-paths/cjs', not the main entry.","wrong":"const xdgAppPaths = require('xdg-app-paths')","symbol":"xdgAppPaths","correct":"const xdgAppPaths = require('xdg-app-paths/cjs')"},{"note":"Deno requires the full URL to the Deno-specific module.","wrong":"import xdgAppPaths from 'xdg-app-paths'","symbol":"xdgAppPaths","correct":"import xdgAppPaths from 'https://deno.land/x/xdg_app_paths@v8.3.0/src/mod.deno.ts'"}],"quickstart":{"code":"import xdgAppPaths from 'xdg-app-paths';\n\n// Get XDG directories for the application named 'myapp'\nconst cacheDir = xdgAppPaths.cache();\nconsole.log('Cache directory:', cacheDir);\n// Linux: /home/user/.cache/myapp\n// macOS: /Users/user/Library/Caches/myapp\n// Windows: C:\\Users\\user\\AppData\\Local\\myapp\\Cache\n\nconst configDir = xdgAppPaths.config();\nconsole.log('Config directory:', configDir);\n// Linux: /home/user/.config/myapp\n// macOS: /Users/user/Library/Application Support/myapp\n// Windows: C:\\Users\\user\\AppData\\Roaming\\myapp\\Config\n\nconst dataDir = xdgAppPaths.data();\nconsole.log('Data directory:', dataDir);\n// Linux: /home/user/.local/share/myapp\n// macOS: /Users/user/Library/Application Support/myapp\n// Windows: C:\\Users\\user\\AppData\\Roaming\\myapp\\Data\n\nconst configDirs = xdgAppPaths.configDirs();\nconsole.log('Config directories (priority order):', configDirs);\n// Linux: ['/home/user/.config/myapp', '/etc/xdg/myapp']\n// macOS: ['/Users/user/Library/Application Support/myapp', '/Library/Application Support/myapp']\n// Windows: ['C:\\Users\\user\\AppData\\Roaming\\myapp\\Config']\n\nconst runtimeDir = xdgAppPaths.runtime();\nconsole.log('Runtime directory:', runtimeDir);\n// Linux: /run/user/1000/myapp\n// macOS: null (not supported)\n// Windows: null (not supported)\n\nconst stateDir = xdgAppPaths.state();\nconsole.log('State directory:', stateDir);\n// Linux: /home/user/.local/state/myapp\n// macOS: /Users/user/Library/State/myapp\n// Windows: C:\\Users\\user\\AppData\\Local\\myapp\\State","lang":"typescript","description":"Demonstrates all major XDG path retrieval methods with cross-platform examples."},"warnings":[{"fix":"Change require('xdg-app-paths') to require('xdg-app-paths/cjs').","message":"Version 8.x changed the required import for CommonJS from 'xdg-app-paths' to 'xdg-app-paths/cjs'. Old CJS code using require('xdg-app-paths') will fail.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Use xdgAppPaths.cache() etc. directly; the function is called without instantiation.","message":"Version 8.x removed the default export of a class; it now exports a function directly. const xdg = new xdgAppPaths() no longer works.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Use a wrapper or pass the app name explicitly? (No built-in override; consider using environment variable XDG_APP_PATHS_NAME or similar workaround.)","message":"The library automatically determines the application name from the calling module's filename (e.g., myapp.js results in 'myapp'). This may not be intended for applications with multiple entry points or different naming conventions.","severity":"gotcha","affected_versions":">=8.0.0"},{"fix":"Always check for null return values on methods not supported on Windows (e.g., runtime).","message":"On Windows, the method 'runtime()' returns null because runtime directories are not part of the XDG spec on Windows. Similarly, 'state()' and 'data()' may return different paths than expected.","severity":"gotcha","affected_versions":">=8.0.0"},{"fix":"Use 'configDirs()' as-is for now, but be prepared for renaming in future major releases.","message":"The method 'configDirs()' returns an array of directories in priority order. In future versions this may be renamed to 'configPaths()' to align with other path methods.","severity":"deprecated","affected_versions":">=8.0.0"}],"env_vars":null,"search_vec":"'8.3.0':24 'activ':31 'app':3 'appdir':58 'applic':12,42,59 'automat':40 'cach':14,60 'call':46 'cjs':26,54 'common':61 'compat':8 'config':15,62 'cross':64 'cross-platform':63 'data':16,66 'deno':30 'deriv':41 'determin':5 'directori':67 'entri':55 'esm':27 'etc':17 'file':13 'filenam':49 'javascript':57 'librari':38 'linux':19 'maco':20 'maintain':32 'modul':47 'name':43 'path':4,9 'platform':65 'point':56 'provid':51 'regular':34 'releas':35 'separ':53 'similar':37 'store':11 'support':25 'typescript':28,68 'unlik':36 'version':23 'window':22 'xdg':2,7 'xdg-app-path':1 'xdg-compat':6","created_at":"2026-06-07T13:01:49.422477+00:00","updated_at":"2026-06-07T13:01:49.422477+00:00","problems":[{"fix":"Change to const xdgAppPaths = require('xdg-app-paths/cjs');","cause":"CommonJS code using require('xdg-app-paths') instead of require('xdg-app-paths/cjs')","error":"Cannot find module 'xdg-app-paths'"},{"fix":"Use 'xdgAppPaths.cache()' etc. directly, no instantiation needed.","cause":"Attempting to instantiate the default export with 'new xdgAppPaths()'","error":"TypeError: xdgAppPaths is not a constructor"},{"fix":"Use 'import xdgAppPaths from 'xdg-app-paths'' (default import).","cause":"Using named import { xdgAppPaths } from 'xdg-app-paths' instead of default import","error":"SyntaxError: The requested module 'xdg-app-paths' does not provide an export named 'xdgAppPaths'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/rivy/js.xdg-app-paths#readme","github":"https://github.com/rivy/js.xdg-app-paths","docs":null,"changelog":null,"pypi":null,"npm":"xdg-app-paths","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}