To create an empty file in Node.js, we use the open method.
For instance, we write
const fs = require("fs");
fs.open(path, "wx", (err, fd) => {
// handle error
fs.close(fd, (err) => {
// handle error
});
});
to call open with the path to open the file at the path.
We create the file since we called it with the w permission.
And then we call close to close the file.