Skip to content
Node.js os.homedir polyfill for older versions of node.js.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes first commit Oct 19, 2016
.gitignore first commit Oct 19, 2016
.travis.yml ensure travis will run on osx and linux for all current node versions Oct 19, 2016 add file Oct 19, 2016
LICENSE first commit Oct 19, 2016
appveyor.yml add appveyor config Oct 19, 2016
index.js Fixing lint issues. Feb 21, 2019
package.json 1.0.3 Feb 21, 2019
polyfill.js extracted polyfill for performance benefits Feb 20, 2019
test.js ensure tests use os.homedir if the node.js version supports it Oct 19, 2016

homedir-polyfill NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

Node.js os.homedir polyfill for older versions of node.js.

Please consider following this project's author, Brian Woodward, and consider starring the project to show your ❤️ and support.


Install with npm:

$ npm install --save homedir-polyfill


var homedir = require('homedir-polyfill');
//=> /Users/doowb


This library is a polyfill for the node.js os.homedir method found in modern versions of node.js.

This implementation tries to follow the implementation found in libuv by finding the current user using the process.geteuid() method and the /etc/passwd file. This should usually work in a linux environment, but will also fallback to looking at user specific environment variables to build the user's home directory if neccessary.

Since /etc/passwd is not available on windows platforms, this implementation will use environment variables to find the home directory.

In modern versions of node.js, os.homedir is used.



Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Related projects

You might also be interested in these projects:

parse-passwd: Parse a passwd file into a list of users. | homepage


Commits Contributor
19 doowb
2 martinheidegger


Brian Woodward


Copyright © 2016 - 2019, Brian Woodward. Released under the MIT License.

This file was generated by verb-generate-readme, v0.8.0, on February 21, 2019.

You can’t perform that action at this time.