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 222 views
2 answers 162 views
2 answers 154 views
1 answer 158 views
1 answer 144 views
1 answer 164 views
...