Received undefined throw new ERR_INVALID_CALLBACK(cb);
In my node-express app I'm stuck here solutions are most welcome
const fs = require("fs");
const text = "File ";
fs.writeFile("node-message.txt", text)
.then(() => {
console.log("File Created");
})
.catch(() => {
console.log("File not created");
});
CodePudding user response:
You have to just require your module with promises as mentioned below code...
const fs = require("fs").promises;
const text = "File ";
fs.writeFile("node-message.txt", text)
.then(() => {
console.log("File Created");
})
.catch(() => {
console.log("File not created");
});