lein cljsbuild失败,出现不可追踪的错误。如何解决cljsbuild错误?

时间:2019-02-12 23:23:58

标签: clojurescript cljsbuild

我没有看到用于编译的任何日志文件,并且终端中的错误不足以让我进一步进行故障排除。 如何获取更多详细的错误日志记录,或者应该如何解决该问题?

下面stacktrace的前几行

Compiling ClojureScript...
Compiling ["resources/public/js/app.js"] from ["src/cljs"]...
Compiling ["resources/public/js/app.js"] failed.
clojure.lang.ExceptionInfo: failed compiling file:resources\public\js\out\cljs\core.cljs {:file #object[java.io.File 0x7c5d1d25 "resources\\public\\js\\out\\cljs\\core.cljs"], :clojure.error/phase :compilation}
        at cljs.compiler$compile_file$fn__3901.invoke(compiler.cljc:1706)
        at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1666)

我有一个包含以下内容的简单cljs文件

(ns moose.core)   
(defn run []
  (.write js/document "This is not the end!"))

我的project.clj具有用于cljsbuild的以下配置

:cljsbuild
  {:builds [{:id           "dev"
             :source-paths ["src/cljs"]
             :figwheel {:on-jsload "moose.core/run"
                        :open-urls ["http://localhost:3449/index.html"]}
             :jar true
             :compiler     {:main moose.core 
                            :warnings true
                            :output-dir "resources/public/js/out" 
                            :asset-path "js/out"
                            :output-to "resources/public/js/app.js"}}]}
  :clean-targets ^{:protect false} [:target-path :compile-path "resources/public/js" "dev-target"]

更新1 遵循以下Alan的建议,我创建了一个新模板,并缩小了添加用于与CouchDB进行交互的相当老的库的原因。

[com.ashafa/clutch "0.4.0"]

问题仍然是如何获取cljsbuild的详细/完整日志。

更新2 原来,库在依赖项列表中的位置有影响。 如果出现在[com.cognitect/transit-clj "0.8.313"]编译失败之前,否则它将起作用。

1 个答案:

答案 0 :(得分:1)

ClojureScript中的配置选项没有详细记录。克隆现有(正在运行的)项目然后从那里进行是最容易的。我建议从the cljs-template project开始,如下所示(请参阅自述文件):

git clone  https://github.com/cloojure/cljs-template.git  demo-0212  ; temp 

> cd demo-0212 
~/expr/demo-0212 > ls -ldF *
-rwxrwxr-x 1 alan alan  222 Feb 12 16:04 npm-install.bash*
-rwxrwxr-x 1 alan alan 4216 Feb 12 16:04 project.clj*
-rw-rw-r-- 1 alan alan 1576 Feb 12 16:04 README.adoc
drwxrwxr-x 3 alan alan 4096 Feb 12 16:04 resources/
drwxrwxr-x 5 alan alan 4096 Feb 12 16:04 src/
drwxrwxr-x 4 alan alan 4096 Feb 12 16:04 test/

~/expr/demo-0212 > ./npm-install.bash 
...<snip>... lots of stuff

此时,您的项目具有单元测试所需的npm内容。

> lein clean
> lein doo phantom test once

;; ======================================================================
;; Testing with Phantom:

doorunner - beginning
doorunner - end

Testing tst.flintstones.dino
test once - enter
globalObject:   #js {:a 1, :b 2, :c 3}
(-> % .-b (+ 5) => 7
(js/makeDino) => #js {:desc blue dino-dog, :says #object[Function]}
dino.desc =>  blue dino-dog
dino.says(5) =>  Ruff-Ruff-Ruff-Ruff-Ruff!
:keep-words ("am" "having" "today")
:re-seq ("am" "having" "today")
test once - leave

Testing tst.flintstones.wilma
test each - enter
test each - leave
test each - enter
wilmaPhony/stats:    #js {:lipstick red, :height 5.5}
wilma => #js {:desc patient housewife, :says #object[Function]}
test each - leave

Testing tst.flintstones.pebbles
test once - enter
test once - leave

Testing tst.flintstones.slate
logr-slate-enter
logr-slate-leave 3

Testing tst.flintstones.bambam
test each - enter
test each - leave
test each - enter
logr-bambam-enter
logr-bambam-leave 3
test each - leave

Ran 9 tests containing 22 assertions.
0 failures, 0 errors.
lein doo phantom test once  38.73s user 1.05s system 313% cpu 12.701 total

您还可以启动齿轮,以在浏览器中查看结果:

> lein clean
> lein figwheel

see new webpage (30-60 sec delay)

------------------------
Figwheel template
Checkout your developer console.

I am a component!

I have bold and red text.
...etc...
------------------------