Node.js: Check if file is an symbolic link when iterating over directory with 'fs'

You can use fs.lstat and then call statis.isSymbolicLink() on the fs.Stats object that's passed into your lstat callback.

fs.lstat('myfilename', function(err, stats) {
    console.log(stats.isSymbolicLink());
});

Seems like you can use isSymbolicLink()

const files = fs.readdirSync(dir, {encoding: 'utf8', withFileTypes: true});
files.forEach((file) => {
  if (file.isSymbolicLink()) {
    console.log('found symlink!');
  }
}