This is the code that is causing the error:
const writeToFile = data => {
return new Promise((resolve, reject) => {
fs.writeFile('./dist/generated-README.md', data, err => {
if (err) {
reject(err);
return;
}
resolve({
ok: true,
message: console.log('File created!')
});
})
})
}
I'm getting an error that says that fs.writeToFile is not a function. Why is that and how do I fix it?
fs.writeToFile is not a function because it's called fs.writeFile. You would need to simply change the name. Also, I'm not sure about that console.Console.log function, It's just console.log.
const writeToFile = data => {
return new Promise((resolve, reject) => {
fs.writeFile('./dist/generated-README.md', data, err => {
if (err) {
reject(err);
return;
}
resolve({
ok: true,
message: console.log('File created!')
});
})
})
}