TypeError: fs.existsSync is not a function

Hi tried changing fs.existsSync to open, access, etc but error persists have nodejs and Blueprint in react create template can anyone help with this have googled and tried quite a number of things but don't know where to go from here any help appreciated Newbie learning javascript

const fs = require('fs');
//const fs = require('fs-extra');
const path = require('path');

class Database {
constructor(filePath, defaultData) {
this.filePath = filePath;
this.defaultData = defaultData;
}

read(prototype) {
if (!fs.existsSync(this.filePath)) return this.defaultData;

var fileContent = fs.readFileSync(this.filePath);
if (fileContent.length === 0) return this.defaultData;

return (prototype) ? prototype.fromJson(JSON.parse(fileContent)) : JSON.parse(fileContent);
}

write(data) {
fs.ensureDirSync(path.dirname(this.filePath));
fs.writeFileSync(this.filePath, JSON.stringify(data));
}
}
//export default Db;
//module.exports = Db;

module.exports = Database;
I don't even wanna know what you're doing with react on MV, but try placing a breakpoint before that line on the debugger and check if `fs` is properly assigned to the right thing.
Hi thanks for that now sorted it was a web pack problem

Original thread: https://forums.rpgmakerweb.com/threads/typeerror-fs-existssync-is-not-a-function.117141/