fs.readFileAsync is not a function
来源:
朗月清风
2016-08-31
Unhandled rejection TypeError: fs.readFileAsync is not a function
at /hope/wechat/libs/util.js:8:12
at Promise._execute (/hope/wechat/node_modules/bluebird/js/release/debuggability.js:299:9)
at Promise._resolveFromExecutor (/hope/wechat/node_modules/bluebird/js/release/promise.js:481:18)
at new Promise (/hope/wechat/node_modules/bluebird/js/release/promise.js:77:14)
at Object.exports.readFileAsync (/hope/wechat/libs/util.js:7:12)
at Wechat.getAccessToken (/hope/wechat/app.js:16:25)
at new Wechat (/hope/wechat/wechat/g.js:18:10)
at module.exports (/hope/wechat/wechat/g.js:80:18)
at Object.<anonymous> (/hope/wechat/app.js:28:9)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:352:7)
'use strict';
var fs = require('fs');
var Promise = require('bluebird');
exports.readFileAsync = function(fpath, encoding) {
return new Promise(function(resolve, reject){
fs.readFileAsync(fpath, encoding, function(err, content) {
if(err) reject(err);
else resolve(content);
})
})
};
exports.writeFileAsync = function(fpath, content) {
return new Promise(function (resolve, reject) {
fs.writeFileAsync(fpath, content, function(err) {
if(err) reject(err);
else resolve();
})
})
};
1回答
-
Scott
2016-08-31
fs 只有 readFile 和 fs.readFileSync,没有 readFileAsync
00
相似问题