1.同步读取
// 创建fs模块
const fs = require('fs');
// 异步读取
fs.readFile('hello.txt', (err, data) => {
console.log('读取失败');
return;
}
console.log(data.toString());
2.异步读取
// 同步读取
let data = fs.readFileSync('hello.txt');
console.log(data.toString());