Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
homedir-polyfill
Advanced tools
The homedir-polyfill npm package provides a simple and consistent way to retrieve the home directory of the current user across different operating systems. This is particularly useful for creating cross-platform applications that need to access or store files in the user's home directory. The package acts as a polyfill for Node.js's os.homedir method, ensuring compatibility even in environments where this method is not available.
Get current user's home directory
This feature allows you to retrieve the current user's home directory as a string. The code sample demonstrates how to import the homedir-polyfill package and use it to print the home directory to the console.
const homedir = require('homedir-polyfill')();
console.log(homedir);
os-homedir is a package that provides similar functionality to homedir-polyfill by offering a way to get the home directory of the current user. It was more relevant before Node.js v2.3.0, as it polyfilled the os.homedir method. Compared to homedir-polyfill, os-homedir serves a similar purpose but may not be as up-to-date or necessary for modern Node.js versions.
user-home is another npm package that retrieves the current user's home directory. It differs from homedir-polyfill by providing a simpler, more direct API without the need to call the function after requiring it. However, it essentially serves the same purpose and has similar compatibility considerations.
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 :heart: and support.
Install with npm:
$ npm install --save homedir-polyfill
var homedir = require('homedir-polyfill');
console.log(homedir());
//=> /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 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
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
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.
FAQs
Node.js os.homedir polyfill for older versions of node.js.
The npm package homedir-polyfill receives a total of 7,077,077 weekly downloads. As such, homedir-polyfill popularity was classified as popular.
We found that homedir-polyfill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.