//clean logs
await writeFileAsync('logs.txt', '');
//clean temp files
await clean_dir(__dirname + '/files/temp');
//connect to db
await mongoose.connect(config.database);
console.log('connected');
await app.listen(port);
console.log(port + ' is listened');
它清理日志文件(实际上是创建一个新文件),但是在清理后立即停止服务器没有错误
const fs = require('fs');
module.exports = (path, data) => {
return new Promise(resolve => {
fs.writeFile(path, data, resolve);
})
}
如果我删除这一行await writeFileAsync('logs.txt', '');
一切都很好。我无法理解发生了什么。有人可以解释一下吗?