【发布时间】:2021-03-08 16:54:21
【问题描述】:
每当我尝试将数据写入 .json 文件时,都会出现错误。它说 'fs.writefile' 不是函数。
我的功能:
const fs = require('fs');
function write(data: Map<string, number>) {
fs.writefile("users.json", JSON.stringify(data), function(err: any) {
if (err) throw err;
console.log('complete');
}
);
}
错误: (node:4408) UnhandledPromiseRejectionWarning: TypeError: fs.writefile is not a function
有人可以帮我解决这个问题吗?
【问题讨论】:
标签: node.js json typescript writefile