Languages
[Edit]
EN

Node.js - check if path is file

3 points
Created by:
Blythe-F
650

In this article, we would like to show you how to check if path is a file using Node.js.

Quick solution:

Warning:

When /path/to/somewhere is soft link and indicates to non-existing path, it is necessary to call fs.existsSync(/path/to/somewhere) before status checking.

 

Practical example

Edit

Projects structure:

Example my_script.js file:

 

TODO

Edit
  1. callbacks based example
  2. async/await based example

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Node.js - file system module

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join