To fix this error TypeError [ERR_INVALID_CALLBACK]: Callback must be a function with Node, we pass in a function as the callback.
For instance, we write
const fs = require("fs");
fs.readFile("readMe.txt", "utf8", (err, data) => {
fs.writeFile("writeMe.txt", data, (err, result) => {
if (err) console.log("error", err);
});
});
to call readFile
with the callback as the 3rd argument.
And we call writeFile
with the callback as the 3rd argument.