title: Node js Get folder path from a file
body: <p>Is there a way to get the path to a folder that holds a particular file.</p>
  
  <pre><code>fs.realpathSync('config.json', []);
  </code></pre>
  
  <p>returns something like</p>
  
  <pre><code>G:\node-demos\7-node-module\demo\config.json
  </code></pre>
  
  <p>I just need</p>
  
  <pre><code>G:\node-demos\7-node-module\demo\ 
  or
  G:\node-demos\7-node-module\demo\
  </code></pre>
  
  <p>Is there any api for this or will I need to process the string?</p>