How To Check a File Exists with Node.js Tutorial

Опубликовано: 01 Июль 2020
на канале: Code With Bubb
5,717
63

In this tutorial you'll learn how to check a file exists with Node.js using the built in file system library available straight out of the box with Node.js.

— Follow Me —
Twitter:   / codebubb  
Facebook:   / juniordevelopercentral  
Blog: https://www.juniordevelopercentral.com/
— Thanks! —

So checking whether a file exists with Node.js can be done in a few ways and you can use some of the built in Node.js file system functions depending on your scenario.

In this Node.js tutorial, you'll learn how to use the exists and existsSync functions and what the differences are between them.

Finally, we'll see how you can use the Node.js promisify function to turn the asynchronous exists function to a promise which is really handy if you want to check if a file exists in Node.js inside a promise chain.

Checking if a file exists with Node.js is handy if you want to make sure the file you want to work with is actually there before then trying to perform certain operations on the file such as trying to read it or move it or do any other operation with it.

Check out the other Junior Developer Central Node.js HowTo videos here:    • Node.js HowTos  

#Node.js Channel Handle @codebubb


Смотрите видео How To Check a File Exists with Node.js Tutorial онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Code With Bubb 01 Июль 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 5,717 раз и оно понравилось 63 людям.