I have the code below in a file named file-create-directory.js when I call this file on the terminal by node file-create-directory.js is giving me an error I see it has something to do with the fs.exists module but I can't figure it out
fs.js:140 throw new ERR_INVALID_CALLBACK(); TypeError [ERR_INVALID_CALLBACK]: Callback must be a function at maybeCallback (fs.js:140:9) at Object.fs.exists (fs.js:218:3)
const fs = require('fs');
if(!fs.exists("views")) {
fs.mkdir("views", (err)=>{
if(err) return err;
fs.writeFile("./views/new.html", 'this is a new directory and data', (err)=>{
if(err) return err;
console.log('Directory and file saved')
})
});
}
fs.existsis deprecated so use this method instead: nodejs.org/api/fs.html#fs_fs_existssync_pathfs.access().