title: Nodejs: path must be a string
body: <p>I tried to implement some code that uses <code>promise</code>, and I copied some source code from Ghost. But when I ran it, I got an error:</p>
  
  <p><strong>The code:</strong></p>
  
  <pre><code>var Promise = require('bluebird')
  var fs = require('fs')
  var path = require('path')
  var configPath = path.join(__dirname, '/config-example.js')
  var configFile
  
  function writeConfigFile(){
      return new Promise(function(resolve,reject){
          var read,
              write,
              error; 
          console.log('path-&gt;', configPath)
          read = fs.createReadStream(configPath);
          read.on('error', function(err){
             console.log('Error-&gt;', err);
             reject(err)
          })
  
         write = fs.createWriteStream(configFile)
         write.on('error', function(err){
            console.log('Error-&gt;',err)
            reject(err)
         })
        write.on('finish', resolve)
        read.pipe(write)
    });
  }
  
  var p = writeConfigFile();
      p.then(function(data){
          console.log(data)
      },function(data){
          console.log('data-&gt;',data)
      });
  </code></pre>
  
  <p><strong>Error Output</strong></p>
  
  <pre><code>path-&gt; /mnt/share/Learn/config-example.js   
  data-&gt; [TypeError: path must be a string]  
  Error-&gt; { [Error: ENOENT, open '/mnt/share/Learn/config-example.js']   
  errno: 34,   code: 'ENOENT', 
  path: '/mnt/share/Learn/config-example.js' }
  </code></pre>