DEV Community 👩‍💻👨‍💻

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)

🌚 Life is too short to browse without dark mode