1. xdg-basedir
Get XDG Base Directory paths
xdg-basedir
Package: xdg-basedir
Created by: sindresorhus
Last modified: Sat, 04 Mar 2023 17:06:23 GMT
Version: 5.1.0
License: MIT
Downloads: 36,492,823
Repository: https://github.com/sindresorhus/xdg-basedir

Install

npm install xdg-basedir
yarn add xdg-basedir

xdg-basedir

Get XDG Base Directory paths

This package is meant for Linux. You should not use XDG on macOS or Windows. Instead, you should follow their platform conventions. You can use env-paths for that.

Install

$ npm install xdg-basedir

Usage

 import {xdgData, xdgConfig, xdgDataDirectories} from 'xdg-basedir';

console.log(xdgData);
//=> '/home/sindresorhus/.local/share'

console.log(xdgConfig);
//=> '/home/sindresorhus/.config'

console.log(xdgDataDirectories);
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']

API

The exports xdgData, xdgConfig, xdgCache, xdgRuntime will return undefined in the uncommon case that both the XDG environment variable is not set and the users home directory can't be found. You need to handle this case. A common solution is to fall back to a temporary directory.

xdgData

Directory for user-specific data files.

xdgConfig

Directory for user-specific configuration files.

xdgState

Directory for user-specific state files.

xdgCache

Directory for user-specific non-essential data files.

xdgRuntime

Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc).

xdgDataDirectories

Preference-ordered array of base directories to search for data files in addition to xdgData.

xdgConfigDirectories

Preference-ordered array of base directories to search for configuration files in addition to xdgConfig.


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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin