title: Node.js: Directory has no method 'basename' when path.basename is used
body: <p>I have an array of files, and I am trying to get just the <code>basename</code> of the files, without their long extensions. Here is an example of what the array looks like:</p>
  
  <pre><code>[ 
    '/public/uploads/contentitems/.DS_Store',
    '/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0.png',
    '/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1.png',
    '/public/uploads/contentitems/2A431412-A776-4D11-841A-B640DF37C9E2/2A431412-A776-4D11-841A-B640DF37C9E2_2.png' 
  ]
  </code></pre>
  
  <p>I want to get:</p>
  
  <pre><code>[ 
    '.DS_Store',
    '063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0.png',
    '063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1.png',
    '2A431412-A776-4D11-841A-B640DF37C9E2/2A431412-A776-4D11-841A-B640DF37C9E2_2.png' 
  ]
  </code></pre>
  
  <p>According to the docs, the <code>path.basename</code> function should return me the file without the path.</p>
  
  <p>But what I get is the following error:</p>
  
  <pre><code>TypeError: Object /public/uploads/contentitems has no method 'basename'
  </code></pre>
  
  <p>Here is the code I am using right now:</p>
  
  <pre><code>    var walk = function(dir, done) {
          var results = [];
          fs.readdir(dir, function(err, list) {
              if (err) return done(err);
              var pending = list.length;
              if (!pending) return done(null, results);
              list.forEach(function(file) {
                  file = dir + '/' + file;
                  fs.stat(file, function(err, stat) {
                      if (stat &amp;&amp; stat.isDirectory()) {
                          walk(file, function(err, res) {
                              results = results.concat(res);
                              if (!--pending) done(null, results);
                          });
                      } else {
                          var suffix = getSuffix(file);
                          if (!verObj[suffix]) results.push(file);
                          if (!--pending) done(null, results);
                      }
                  });
              });
          });
      };
  
      walk(path, function(err, results) {
          if (err) throw err;
          results.forEach(function(file) {
              console.log(path.basename(file));
          });
          self.respond({files: results}, {format: 'json'});
      });
  </code></pre>
  
  <p>I am using <code>path = require('path');</code> at the top of my file as well.</p>