npm install bluebird
var Promise = require(‘bluebird‘)
const fs = Promise.promisifyAll(require(‘fs‘))
fs.readFileAsync(‘./1.j‘).then(value => {
console.log(value.toString());
}).catch(err => {
console.log(err);
})
fs.writeFileAsync(‘驿外.txt‘, ‘驿外断桥边‘).then(value => {
console.log(value);
})
原文:https://www.cnblogs.com/dingtongya/p/14773744.html