I'm trying to use ExcelJS in NestJS. For some reason, I can not open xlsx file.
exceljs uses this code for checking if file exists
fs: {
exists: function exists(path) {
return new Promise(function (resolve) {
console.log(path);
fs.access(path, fs.constants.F_OK, function (err) {
resolve(!err);
});
});
}
},
that code returns Cannot read property 'F_OK' of undefined. Console.log on line 4 returns path I send it correctly
However, if I try to access the same file form my service with this code
fs.access(this.file, fs.constants.F_OK | fs.constants.W_OK, (err) => {
if (err) {
console.error(
`${this.file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);
} else {
console.log(`${this.file} exists, and it is writable`);
}
});
That code returns "file.xlsx exists, and it is writable". What is the difference and why I can't read the same file with exceljs?
fs
library? I think it has to do withfs/promises
andfs