I thought I could do it with the 'fs' module, but i couldnt find the right function.
Asked
Active
Viewed 8,607 times
0
-
2I believe this question has already been answered here: http://stackoverflow.com/questions/4482686/check-synchronously-if-file-directory-exists-in-node-js – James Corr Jan 12 '12 at 20:11
-
thanks. I dont know how i missed it.. – kakush Jan 12 '12 at 20:17
2 Answers
2
fs = require('fs');
fs.exists(path, function( exists ) {
console.log( ( exists ? "File is there" : "File is not there" ) );
});

Nosherwan Adil
- 141
- 1
- 5
-
1fs = require('fs'); console.log( fs.statSync(path).isFile() ); // True or False – Nosherwan Adil May 27 '13 at 14:08
1
See the documentation for the fs
module, in particular the "stat
" family of functions (stat, fstat, lstat, statSync, fstatSync, lstatSync).

maerics
- 151,642
- 46
- 269
- 291