Problem with ClojureScript and Node.js

587 views
Skip to first unread message

Benny Tsai

unread,
Jul 24, 2011, 1:31:26 AM7/24/11
to clo...@googlegroups.com
I'm experimenting with the latest build of ClojureScript from github on Windows.  I can get as far as compiling nodehello.cljs from the Quick Start guide, but I get the following error when trying to run the compiled .js file with Node:

node.js:195
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
GetConsoleTitleW: The access code is invalid.
TypeError: Cannot read property 'prototype' of undefined
    at Object.<anonymous> (C:\clojurescript\nodehello.js:13:382)
    at Module._compile (module.js:420:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:335:31)
    at Function._load (module.js:294:12)
    at Array.<anonymous> (module.js:479:10)
    at EventEmitter._tickCallback (node.js:187:26)

I get that error with both 0.5.2 and 0.5.1 binaries from nodejs.org/dist/, and a similar error with the 0.4.9 and 0.4.8 binaries from node-js.prcn.co.cc/:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
WideCharToMultiByte: The data area passed to a system call is too small.
TypeError: Cannot read property 'prototype' of undefined
    at Object.<anonymous> (/cygdrive/c/clojurescript/nodehello.js:13:382)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at Array.<anonymous> (module.js:421:10)
    at EventEmitter._tickCallback (node.js:126:26)

Has anyone had success with ClojureScript + Node.js, on Windows or otherwise?

Benny Tsai

unread,
Jul 24, 2011, 1:53:25 AM7/24/11
to clo...@googlegroups.com
I should add that I did have to make one change to closure.clj in order to compile nodehello.cljs; I changed the following line in the ns->file-name function:

  path (string/replace (munge ns) \. java.io.File/separatorChar)]

To:

  path (string/replace (munge ns) \. \/)]

Ulrik Sandberg

unread,
Jul 24, 2011, 6:41:59 PM7/24/11
to Clojure
I have the same problem, using an unmodified clojurescript checkout
(08db38f) with nodejs 0.4.10 on MacOSX 10.6.8.

$ cat nodehello.cljs
(ns nodehello)

(defn -main [& args]
(println (apply str (map [\ "world" "hello"] [2 0 1]))))

(set! *main-cli-fn* -main)
$ bin/cljsc nodehello.cljs
'{:optimizations :advanced :target :nodejs}' > nodehello.js
$ node nodehello.js

node.js:134
throw e; // process.nextTick error, or 'error' event on first
tick
^
TypeError: Cannot read property 'prototype' of undefined
at Object.<anonymous> (/Source/Git/clojurescript/nodehello.js:
14:382)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at Array.<anonymous> (module.js:421:10)
at EventEmitter._tickCallback (node.js:126:26)

Benny Tsai

unread,
Jul 24, 2011, 10:13:55 PM7/24/11
to clo...@googlegroups.com
Thank you for your response, Urlik.  It's good to know someone else saw the same error, on a non-Windows platform, no less.  Sean Corfield, responding to an earlier failed attempt by me to post about the problem, said that he was able to use Node with ClojureScript on OSX after following the instructions at https://github.com/joyent/node/wiki/Installation and building Node 0.4.11-pre from source.  Perhaps that might work for you as well?

If anyone else has experienced this problem, please feel free to chime in!

Oliver Kaiser

unread,
Jul 25, 2011, 8:51:17 PM7/25/11
to clo...@googlegroups.com
I also experience this problem; switching nodejs versions (0.4.11-pre
== v0.4 branch, 0.4.10 and 0.5.2) did not have any effect.

When compiling with:
bin/cljsc samples/nodehello.cljs '{:target :nodejs :optimizations
:simple :pretty-print true}' > nodehello.js

the (first) relevant line for this error seems to be:
goog.global.Date.prototype.cljs$core$IEquiv$ = !0;

I don't get why this is goog.global.Date and not goog.date.Date, or
where the definition should actually come from; somehow it smells like
config trouble or (most likely) user error.

Regards,
tok

Oliver Kaiser

unread,
Jul 27, 2011, 1:26:12 PM7/27/11
to clo...@googlegroups.com
I seem to have fixed this by editing
closure/library/closure/goog/base.js and rebuilding lib/goog.jar.
The relevant line is "goog.global = this;" somewhere at the top where
"this" should be replaced by
"(function(){return this})();"; the bootstrap script contains the
command to create the jarfile.

I can't tell if this is the ~correct~ way of fixing this problem, but
so far it doesn't appear to have broken
anything. Tested with v0.4 branch and 0.5.2 release, both work.

Regards,
tok

Anthony Grimes

unread,
Jul 28, 2011, 6:32:14 PM7/28/11
to clo...@googlegroups.com
I'm all of a sudden getting this exact same error on OS X 10.6.8. And I do mean all of a sudden. I actually updated to this version of OS X last night and today it isn't working. Is this happening to any OS X users on an older Snow Leopard? This is the only thing that has changed in my setup, so I'm actually starting to wonder if it might have something to do with that.

Anthony Grimes

unread,
Jul 28, 2011, 7:10:57 PM7/28/11
to clo...@googlegroups.com
Actually, it seems to be caused by this commit: https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af77d6035f90e93a9126ea

If I checkout before that, everything is peachy. I guess I'll submit a bug report.

Rich Hickey

unread,
Jul 28, 2011, 7:40:39 PM7/28/11
to clo...@googlegroups.com
Could you please use quoting in your messages? Otherwise they have no
context.

Thanks,

Rich

Anthony Grimes

unread,
Jul 28, 2011, 7:50:37 PM7/28/11
to clo...@googlegroups.com
Oh! I apologize. I was replying via the google interface and didn't realize it wasn't quoting. Here is a link to the topic for context: https://groups.google.com/d/topic/clojure/ZyVrCxmOFTM/discussion

I've also filed a bug here: http://dev.clojure.org/jira/browse/CLJS-43

Sorry. :)

Benny Tsai

unread,
Jul 30, 2011, 9:42:09 PM7/30/11
to clo...@googlegroups.com
Thank you for tracking it down and doing the legwork, Anthony :)

Mark McGranaghan

unread,
Aug 17, 2011, 11:25:54 AM8/17/11
to Clojure


On Jul 28, 4:50 pm, Anthony Grimes <disciplera...@gmail.com> wrote:
> Oh! I apologize. I was replying via the google interface and didn't realize
> it wasn't quoting. Here is a link to the topic for
> context:https://groups.google.com/d/topic/clojure/ZyVrCxmOFTM/discussion
>
> I've also filed a bug here:http://dev.clojure.org/jira/browse/CLJS-43

I've been trying to get the hello world ClojureScript + Node.js
example working, but have been hitting the problems described in this
thread. I see that this ticket for this issue is still open:

http://dev.clojure.org/jira/browse/CLJS-43

But that the one it points to as being the possible root cause is
closed:

http://dev.clojure.org/jira/browse/CLJS-25

Is Node.js expected to be working in ClojureScript HEAD, for example
in the form described here?:

https://github.com/clojure/clojurescript/wiki/Quick-Start

If it is known/expected to be not working, how might I help get it
working again? Is there a specific blocker, or is it just that support
has regressed because of a changing code base and needs to be
investigated/refreshed?

I'm anxious to help but am not sure where to start: any pointers would
be appreciated.

- Mark


> Sorry. :)
>
>
>
> On Thursday, July 28, 2011 6:40:39 PM UTC-5, Rich Hickey wrote:
>
> > Could you please use quoting in your messages? Otherwise they have no  
> > context.
>
> > Thanks,
>
> > Rich
>
> > On Jul 28, 2011, at 7:10 PM, Anthony Grimes wrote:
>
> > > Actually, it seems to be caused by this commit:
> >https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af7...

Javier Neira Sanchez

unread,
Aug 27, 2011, 5:59:24 AM8/27/11
to clo...@googlegroups.com
Hi people! i am experimenting with clojurescript and node.js in windows too and i cant to access public node.js vars like __dirname. I had to use (js* "__dirname") but i think it would be neat that cljs.nodejs had all the global vars of node.js

Thanks for clojurescript and keep on it!

Christopher Redinger

unread,
Aug 30, 2011, 9:58:31 AM8/30/11
to clo...@googlegroups.com
I checked in a change this morning that fixes this.

On Wednesday, August 17, 2011 11:25:54 AM UTC-4, Mark McGranaghan wrote:
Reply all
Reply to author
Forward
0 new messages