Weird fs error in Node

This code unintentionally joins the full path of the directory containing my script with each file and directory in DIR. What I want is the correct path of each file and directory in DIR to use as an argument for fs.lstat.

Here’s the code:

fs.readdir(DIR, (err, files) => {
    if (err) {
       return console.error(err);
    }
    files.forEach(file => {
        fs.lstat(file, (err, stats) => {
            if (err) {
                return console.error(err);
            }
            console.log(stats.isDirectory());
        });
    });
 });

This solves the problem:

const abspath = path.resolve(DIR, file);

See https://jaketrent.com/post/paths-in-node/ for an explanation.