title: How to connect a ClojureScript node REPL to my :node-library shadow-cljs project?
body: <p><strong>Context</strong></p>
  
  <p>I am building a Node.js library with ClojureScript and <a href="https://stackoverflow.com/q/52894430/1244884">shadow-cljs</a>. <br>
  All development is done with ClojureScript but the build artefact is a NPM package. Example:</p>
  
  <pre class="lang-clj prettyprint-override"><code>(ns com.example.answer)
  
  (defn answer [] 42)
  </code></pre>
  
  <p><em>build... release... then</em></p>
  
  <pre><code>const answer = require('answer');
  answer(); //=&gt; 42
  </code></pre>
  
  <p><em>NB: I recently contributed the details of my build setup to <a href="https://stackoverflow.com/q/52894430/1244884">this post</a>.</em></p>
  
  <p>My entire development environment is in a Docker container and I am using the "Visual Studio Code Remote - Container" extension.</p>
  
  <ul>
  <li>ClojureScript v1.10</li>
  <li>Node.js v12</li>
  <li><a href="http://shadow-cljs.org/" rel="noreferrer">shadow-cljs</a> v2.8.55</li>
  <li>Visual Studio Code <a href="https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva" rel="noreferrer">Calva</a> extension (running in a <a href="https://code.visualstudio.com/docs/remote/containers" rel="noreferrer">VS Code remote container</a>)</li>
  </ul>
  
  <p><strong>The "Problem"</strong></p>
  
  <p>My build setup works fine (at least I think so!) but I'd like to implement a faster development feedback cycle.<br>
  In other words: I don't want to rebuild an entire NPM package just to test a few lines of change.</p>
  
  <p><strong>The Perfect World</strong> <em>aka "the question"</em></p>
  
  <p>In a perfect world I should be able to have a REPL open and be able to evaluate my ClojureScript code at all time.</p>
  
  <p>No matter how I try to get there I seem to be blocked by the same underlying problem:</p>
  
  <blockquote>
    <p>No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.</p>
  </blockquote>
  
  <p><strong>What I tried</strong></p>
  
  <ol>
  <li><p>With <code>shadow-cljs</code> only:</p>
  
  <p>Given the following <code>shadow-cljs.edn</code> file:</p>
  
  <pre class="lang-clj prettyprint-override"><code>;; shadow-cljs configuration
  {:source-paths
  ["src"]
  
  :builds
  {:lib {:target :node-library
          :output-to "dist/index.js"
          :exports {:citation citegen.processor.main/citation}}}}
  </code></pre>
  
  <p>First watch:</p>
  
  <pre><code>root@97db64e5dfa3:/workspaces/citegen# cd packages/csl-processor/
  root@97db64e5dfa3:/workspaces/citegen/packages/csl-processor# yarn shadow-cljs cljs-repl lib
  yarn run v1.17.3
  $ /workspaces/citegen/node_modules/.bin/shadow-cljs cljs-repl lib
  shadow-cljs - config: /workspaces/citegen/packages/csl-processor/shadow-cljs.edn  cli version: 2.8.52  node: v12.10.0
  shadow-cljs - socket connect failed, server process dead?
  shadow-cljs - updating dependencies
  ...
  shadow-cljs - dependencies updated
  shadow-cljs - server version: 2.8.52 running at http://localhost:9630
  shadow-cljs - nREPL server started on port 36017
  [0:0]~cljs.user=&gt;
  </code></pre>
  
  <p>Then in another terminal: (note the error message)</p>
  
  <pre><code>root@97db64e5dfa3:/workspaces/citegen# cd packages/csl-processor/
  root@97db64e5dfa3:/workspaces/citegen/packages/csl-processor# yarn shadow-cljs cljs-repl lib
  yarn run v1.17.3
  $ /workspaces/citegen/node_modules/.bin/shadow-cljs cljs-repl lib
  shadow-cljs - config: /workspaces/citegen/packages/csl-processor/shadow-cljs.edn  cli version: 2.8.52  node: v12.10.0
  shadow-cljs - connected to server
  [1:1]~cljs.user=&gt; (inc 41)
  No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
  </code></pre></li>
  <li><p>With VS Code <a href="http://shadow-cljs.org/" rel="noreferrer">Calva</a>:</p>
  
  <p>Given the same <code>shadow-cljs.edn</code> file as above:</p>
  
  <p><a href="https://i.stack.imgur.com/AEmWO.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/AEmWO.gif" alt="enter image description here"></a></p>
  
  <p>When I try to manually load the namespace with <code>Calva: Load current namespace in REPL window</code>, I get the same error:</p>
  
  <blockquote>
    <p>No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.</p>
  </blockquote></li>
  </ol>
  
  <p><strong>Question:</strong> How do I get to that perfect world?</p>