How to check synchronously if directory exists in Node.js

1 Answer

0 votes
const fs = require('fs');

const dir = 'test';

if (fs.existsSync(dir)) {
    console.log(`${dir} Exists`);
} else {
    console.log(`${dir} Not exists`);
}


     
/*
run:
   
test Exists
 
*/

 



answered Mar 9, 2020 by avibootz

Related questions

1 answer 227 views
2 answers 168 views
2 answers 158 views
1 answer 163 views
1 answer 146 views
1 answer 167 views
...