Here is my code
var Promise = require('bluebird');
var fse = Promise.promisifyAll(require('fs-extra'));
fse.remove('./myDir').then(function () {
console.log('Remove myDir done.')
});
I always get TypeError: Cannot read property 'then' of undefined
error.
Version:
node: v6.9.2
bluebird: 3.4.7
fs-extra: 1.0.0
I searched and found a similar question but not exactly quite the same, and I tried that answer, unfortunately, it can't solve my problem.
Did I miss anything?
I found the correct way is
fse.removeAsync
, addAsync
suffix tofse.remove
, please see bluebird API here. Hope it can help others.Update:
With the latest
fs-extra
, I don't need to importbluebird
anymore. See here, below syntax works well.