1. user-home
Get the path to the user home directory
user-home
Package: user-home
Created by: sindresorhus
Last modified: Tue, 07 Nov 2023 05:03:19 GMT
Version: 3.0.0
License: MIT
Downloads: 7,464,962
Repository: https://github.com/sindresorhus/user-home

Install

npm install user-home
yarn add user-home

Deprecated. Just use import {homedir} from 'os';.


user-home

Get the path to the user home directory

Install

$ npm install user-home

Usage

 const userHome = require('user-home');

console.log(userHome);
//=> '/Users/sindresorhus'

Returns null in the unlikely scenario that the home directory can't be found.

FAQ

Why not just use the os-home module?

This module was made long before os-homedir. When Node.js decided to add a native method for getting the user's home directory, I made a polyfill matching its API and decided to depend on it here, so not to have duplicate code. The main reason this one is still around is that lots of modules depend on it and I see no reason to inconvenience dependents by deprecating this. This one also gets the home directory on startup and returns a string rather than exposing a method, so it's faster, and I prefer this API. Modules are cheap in Node.js, so doesn't matter. Use whichever you prefer. I'm going to continue using this one.

  • user-home-cli - CLI for this module
  • home-or-tmp - Get the user home directory with fallback to the system temp directory

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.

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