Categories
JavaScript Answers

How to find home directory in platform agnostic way with Node.js?

Spread the love

Sometimes, we want to find home directory in platform agnostic way with Node.js.

In this article, we’ll look at how to find home directory in platform agnostic way with Node.js.

How to find home directory in platform agnostic way with Node.js?

To find home directory in platform agnostic way with Node.js, we can use the os.homedir method.

For instance, we write

const os = require('os');

console.log(os.homedir());

to call os.homedir to return the home directory path as a string.

Conclusion

To find home directory in platform agnostic way with Node.js, we can use the os.homedir method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *