title: Listing files in __dirname
body: <p>I'm learning ClojureScript and I'm trying to list files in <code>__dirname</code>, I can't get that to work, I suppose the problem is in how I get <code>__dirname</code> itself.</p>
  
  <p>I have it working for a defined folder</p>
  
  <pre><code>(ns namespace
    (:require [cljs.nodejs :as node]))
  
  (def fs (node/require "fs"))
  
  (.readdirSync fs "/home/me")
  </code></pre>
  
  <p>But when I do</p>
  
  <pre><code>(ns namespace
    (:require [cljs.nodejs :as node]))
  
  (def fs (node/require "fs"))
  
  (.readdirSync fs node/__dirname)
  </code></pre>
  
  <p>I don't get anything, when I <code>cider-eval-last-sexp</code>. <code>node/__dirname</code> evaluates to <code>nil</code>, and I have this in the compiler output</p>
  
  <blockquote>
    <p>WARNING: Use of undeclared Var cljs.nodejs/__dirname</p>
  </blockquote>
  
  <p>So, two questions:</p>
  
  <ol>
  <li>I know that the final compiled script gets put in target/ so I should consider that the base folder, how do I specify this in my code?</li>
  <li>I am using Spacemacs, I noticed errors go in <em>cider-repl CLJS my-project</em> buffer, how can I get them printed in the source buffer?</li>
  </ol>
  
  <p>Thank you for any help!</p>