如何在终端中快速启动ClojureScript REPL?我不需要连接浏览器,只需要REPL来评估表达式。
文档似乎假定您要进行浏览器同步,或者提供复杂的技巧来获得简单的REPL。
如何在终端中快速启动ClojureScript REPL?我不需要连接浏览器,只需要REPL来评估表达式。
文档似乎假定您要进行浏览器同步,或者提供复杂的技巧来获得简单的REPL。
Using instructions from here https://github.com/clojure/clojurescript/wiki/Quick-Start#nodejs-repl as inspiration:
Create node_repl.clj
where you have the jar file with this contents:
(require 'cljs.repl)
(require 'cljs.repl.node)
(cljs.repl/repl (cljs.repl.node/repl-env))
Execute with java -cp cljs.jar clojure.main node_repl.clj
. This should open the repl, like this:
$ java -cp cljs.jar clojure.main node_repl.clj
ClojureScript Node.js REPL server listening on 50658
To quit, type: :cljs/quit
ClojureScript:cljs.user> (+ 1 2)
3
rlwrap
(rlwrap java -cp cljs.jar clojure.main node_repl.clj
)。编辑
如果您希望不使用node.js获取可工作的repl,可以使用nashorn(java 8 js虚拟机)或rhino(旧版基于java的js虚拟机),将步骤3和4替换为以下步骤:
对于Nashorn
Create nashorn_repl.clj
where you have the jar file with this contents:
(require 'cljs.repl)
(require 'cljs.repl.nashorn)
(cljs.repl/repl (cljs.repl.nashorn/repl-env))
Execute with java -cp cljs.jar clojure.main nashorn_repl.clj
. This should open the repl, like this:
$ java -cp cljs.jar clojure.main nashorn_repl.clj
To quit, type: :cljs/quit
ClojureScript:cljs.user> (+ 1 2)
3
对于Rhino
Create rhino_repl.clj
where you have the jar file with this contents:
(require 'cljs.repl)
(require 'cljs.repl.rhino)
(cljs.repl/repl (cljs.repl.rhino/repl-env))
Execute with java -cp cljs.jar clojure.main rhino_repl.clj
. This should open the repl, like this:
$ java -cp cljs.jar clojure.main rhino_repl.clj
To quit, type: :cljs/quit
ClojureScript:cljs.user> (+ 1 2)
3