DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 967,911 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Omar Dulaimi
Omar Dulaimi

Posted on

Check user's permissions on file/dir in Nodejs

The ๐—ณ๐˜€๐—ฃ๐—ฟ๐—ผ๐—บ๐—ถ๐˜€๐—ฒ๐˜€.๐—ฎ๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ method tests a user's permissions for the file or directory specified by path.

This is the recommended method by ๐—ก๐—ผ๐—ฑ๐—ฒ๐—ท๐˜€ and the replacement of ๐—ณ๐˜€.๐—ฒ๐˜…๐—ถ๐˜€๐˜๐˜€, as it was deprecated.

Also it's usually not a good idea to use the sync version ๐—ณ๐˜€.๐—ฒ๐˜…๐—ถ๐˜€๐˜๐˜€๐—ฆ๐˜†๐—ป๐—ฐ since it blocks the main thread.

It's better than ๐—ณ๐˜€.๐—ฒ๐˜…๐—ถ๐˜€๐˜๐˜€ as you can see; promisified and provides more modes than just checking if the file exists.

I enjoyed learning about this method, hopefully you did too!


Did you learn something new today?

Like and share this post, and follow me for more!

access method

Top comments (0)

Need a better mental model for async/await?

Check out this classic DEV post on the subject.

โญ๏ธ๐ŸŽ€ JavaScript Visualized: Promises & Async/Await

async await