请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

fs.readFileAsync is not a function

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();
       })
   })
};


正在回答 回答被采纳积分+3

1回答

Scott 2016-08-31 21:07:28

fs 只有 readFile 和 fs.readFileSync,没有 readFileAsync

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信