I am getting the Error, I am writing a function to monitor a path for. I am new to Node.js:
TypeError: Cannot read property 'map' of undefined
at C:\Users\a\Desktop\DL\file\filemonitor.js:15:14 at FSReqWrap.oncomplete (fs.js:149:20)
const Promise = require ('bluebird');
var fs = Promise.promisifyAll(require("fs"));
monitordir(monitorpath) {
var fileList = [];
return new Promise((resolve, reject) => {
fs.readdir(monitorpath,function(err, items) {
items.map((file) => {
fileList.push(file);
});
resolve(fileList);
});
})
}
Note: I don't see a package.json file either. Should I have a sucessful run to see it