Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9214355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:57:27+00:00 2026-06-18T01:57:27+00:00

I’m trying to connect to a ClojureScript browser REPL, and I’m having trouble with

  • 0

I’m trying to connect to a ClojureScript browser REPL, and I’m having trouble with clojure.browser.repl/connect. My compiled JavaScript throws a TypeError trying to call appendChild on a null object in the block of Google Closure code at the top. I’m following the instructions in ClojureScript: Up and Running (Chapter 9, p.78, available in the preview), and wondering if the tooling for this has changed since it was published.

I’m using Leiningen 2.0.0, Java 1.6.0_37, OS X 10.7.5, plus the dependencies in my project.clj:

(defproject brepl-hello "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.clojure/clojurescript "0.0-1552"]
                 [compojure "1.1.5"]
                 [ring/ring-jetty-adapter "1.1.8"]]
  :plugins [[lein-cljsbuild "0.3.0"]]
  :source-paths ["src/clj"]
  :cljsbuild {:builds [{
                :source-paths ["src/cljs"]
                :compiler {
                 :output-to "resources/public/brepl-hello.js"
                 :optimizations :whitespace 
                 :pretty-print true}}]})

Here’s the only ClojureScript source file, src/cljs/brepl_hello/brepl-hello.cljs:

(ns brepl-hello
  (:require [clojure.browser.repl :as repl]))

(repl/connect "http://localhost:9000/repl")

This compiles to the file resources/public/brepl-hello.js, which I’ve inserted into index.html in the same directory:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <script type="text/javascript" src="brepl-hello.js"></script>
    </head>
    <body>
    </body>
</html>

I’ve been serving this on port 3000 with Ring/Jetty from the REPL or Python SimpleHTTPServer. When I open this page in Chrome, the dev console shows Uncaught TypeError: Cannot call method 'appendChild' of null, with a traceback to this if/else block in the Google Closure code at the top of the complied js file, where parentElm (passed in to the containing function as a parameter) is null.

if(goog.userAgent.GECKO || goog.userAgent.WEBKIT) {
    window.setTimeout(goog.bind(function() {
      parentElm.appendChild(iframeElm);
      iframeElm.src = peerUri.toString();
      goog.net.xpc.logger.info("peer iframe created (" + iframeId + ")")
    }, this), 1)
  }else {
    iframeElm.src = peerUri.toString();
    parentElm.appendChild(iframeElm);
    goog.net.xpc.logger.info("peer iframe created (" + iframeId + ")")
  }

This seems to be a problem with clojure.browser.repl/connect. Swapping out this line in the ClojureScript source for something like:

(ns brepl-hello
  (:require [clojure.browser.repl :as repl]))

(.write js/document "Hello World!")

Will compile and run in the browser just fine. I suspect something is misconfigured in my build settings or directory structure, or I’m making a noob mistake somewhere in all this. What’s changed since the time the instructions I’m following were published? I found a couple references to this problem in the #clojure irc logs, but no solution.

Finally, here’s an abbreviated directory tree for reference:

├── out
│   ├── cljs
│   │   ├── core.cljs
│   │   └── core.js
│   ├── clojure
│   │   └── browser
│   │       ├── event.cljs
│   │       ├── event.js
│   │       ├── net.cljs
│   │       ├── net.js
│   │       ├── repl.cljs
│   │       └── repl.js
│   └── goog
│       └── [...] 
├── pom.xml
├── project.clj
├── resources
│   └── public
│       ├── brepl-hello.js
│       └── index.html
├── src
│   ├── clj
│   │   └── brepl_hello
│   │       └── core.clj
│   └── cljs
│       └── brepl_hello
│           └── brepl-hello.cljs
└─── target
     ├── brepl-hello-0.1.0-SNAPSHOT.jar
     ├── classes
     ├── cljsbuild-compiler-0
     │   ├── brepl_hello
     │   │   └── brepl-hello.js
     │   ├── cljs
     │   │   ├── core.cljs
     │   │   └── core.js
     │   └── clojure
     │       └── browser
     │           ├── event.cljs
     │           ├── event.js
     │           ├── net.cljs
     │           ├── net.js
     │           ├── repl.cljs
     │           └── repl.js
     └── stale
         └── extract-native.dependencies
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:57:28+00:00Added an answer on June 18, 2026 at 1:57 am

    Well, its open source and looking at the code it seems that document.body is null at the time the repl hidden iframe is being added to it (the connect call leads to this point).

    You should do this connect call on dom ready or body on load and it should work fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.