title: ENOENT ERROR using fs.unlink in a Express.js Simple APP?
body: <p>js.And i'm creating a simple blog in express.js.
  I use   <a href="https://github.com/typicode/lowdb" rel="nofollow">Typicode/lowdb as database</a> , to create/update/delete, posts based on the id on a data.json file.And use the slug data in the json array to create/update/delete markdown posts with the <strong>Node.js File System API</strong>.On the <strong>delete side</strong>  of the markdown posts i get an error that i don't understand.</p>
  
  <pre><code>  { [Error: ENOENT, unlink 'C:\Users\path\to\publicfolder\undefined.md']
    errno: -4058,
    code: 'ENOENT',
    path: 'C:\\Users\\path\\to\\publicfolder\\undefined.md' }
  </code></pre>
  
  <p>I'm using <strong>fs.unlink</strong> like this to remove markdown posts:</p>
  
  <pre><code>   var oldSlug = "public/"+req.params.slug+".md";   
  
  fs.unlink(oldSlug, function(err) {
      if(err) {
        console.log(err);
      } else {
        console.log("Deleted the old markdown file: " + oldSlug +"");
      }
    });
  </code></pre>
  
  <p>Here is some example of the code exposed by parts:</p>
  
  <p><strong>Example to create/update/delete Posts - Post.js</strong></p>
  
  <pre><code>       exports.index = function (req, res) {
          res.render('post/index', { posts: db.list()});
      }; 
  
      exports.form = function (req, res) {
              res.render('post/form');
          };
  
          exports.edit = function (req, res) {
          var post = db.getById(req.params.id);
          res.render('post/edit', {post: post})
          }
  
         exports.update = function (req, res) {
  
          var slugTitle = slug(req.body.name).toLowerCase().split('.').join("");
  
          var description = req.body.desc;
  
      db.update({id: req.body.id, name: req.body.name, desc: req.body.desc,
      slug: slugTitle});
  
  //using this to rename and update markdown posts it work's
  
          var oldPath = "public/"+req.body.slug+".md";
           var newPath = "public/"+slugTitle+".md"; 
  
           fs.unlink(oldPath, function(err) {
              if(err) {
                console.log(err);
              } else {
                console.log("Deleted the old markdown file : oldPath ");
              }
            }); 
          fs.writeFile(newPath, description, function(err) {
                      if(err) {
                        console.log(err);
                      } else {
                        console.log("The post was updated as: newPath ");
                      }
                    }); 
          res.redirect('/post');};
  
          exports.remove = function (req, res) {
              db.remove(req.params.id);
  
  //using this to delete markdown posts i get the error
  //changing req.params.slug to req.body.slug still gives the error 
  
            var oldSlug = "public/"+req.params.slug+".md"; 
              fs.unlink(oldSlug, function(err) {
              if(err) {
                console.log(err);
              } else {
                console.log("Deleted the markdown file: " + oldSlug +"");
              }
            });
          res.redirect('/post');};
  </code></pre>
  
  <p><strong>Example on Server.js</strong></p>
  
  <pre><code>app.get('/post', post.index);
  app.get('/post/create', post.form);
  app.post('/post/create', post.save);
  app.get('/post/details/:id', post.details);
  app.get('/post/edit/:id', post.edit);
  app.post('/post/update', post.update);
  app.get('/post/delete/:id', post.remove);
   http.createServer(app).listen(app.get('port'), function(){
      console.log("Express server listening on port " + app.get('port'));
   });
  </code></pre>
  
  <p><strong>Example of a index.jade</strong></p>
  
  <pre><code>doctype
  html
      head
          title
      body
          h1 Posts
          ul
          each item in posts
              li Item #{item.name} - #{item.desc} - #{item.slug} 
                  a(href='/post/details/#{item.id}') Details -
                  a(href='/post/edit/#{item.id}') Edit -
                  a(href='/post/delete/#{item.id}') Delete
          div
              p
                  a(href='post/create') Add new
  </code></pre>
  
  <p><strong>The problem is on the exports.remove function in post.js file but why??I believe i'm identifying the markdown file to delete that corresponds to the Slug params from the document in the database or not?</strong> I Hope i'm making sense in the code.</p>