N
N
Nikita Kudrin2020-11-05 00:06:54
Node.js
Nikita Kudrin, 2020-11-05 00:06:54

How to check if a folder exists?

How to use fs to check if a folder exists or not?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2020-11-05
@HepkaPlay

var fs = require('fs');

fs.stat('path/to/dir', function(err) {
    if (!err) {
        console.log('Директория есть');
    }
    else if (err.code === 'ENOENT') {
        console.log('директории нет');
    }
});

K
Kirill Gorelov, 2020-11-05
@Kirill-Gorelov

https://stackoverflow.com/questions/4482686/check-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question