bluebird - fs.readdir().then - cannot read propery then of undefined
<p>I am trying to promisify the <a href="https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback" rel="nofollow noreferrer">fs readdir</a> function using <a href="http://bluebirdjs.com/docs/api/promisification.html" rel="nofollow noreferrer">bluebird</a>. I just want to read all the files in a directory, and then output the array with <code>console.log</code>.</p>

<pre><code>const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs'));

fs.readdir('./XML').then(function(err, directories) {
  console.log(directories);
});
</code></pre>

<p>I get the following output:</p>

<blockquote>
  <p>fs.readdir('./XML').then(function(err, directories) {
                     ^</p>
  
  <p>TypeError: Cannot read property 'then' of undefined
      at Object. (/Users/shooshte/Sportradar/notThatKindOfPeon/bluebird.js:4:20)
      at Module._compile (module.js:570:32)
      at Object.Module._extensions..js (module.js:579:10)
      at Module.load (module.js:487:32)
      at tryModuleLoad (module.js:446:12)
      at Function.Module._load (module.js:438:3)
      at Module.runMain (module.js:604:10)
      at run (bootstrap_node.js:394:7)
      at startup (bootstrap_node.js:149:9)
      at bootstrap_node.js:509:3</p>
</blockquote>

<p>What am I doing wrong?</p>