簡體   English   中英

lein cljsbuild 因無法追蹤的錯誤而失敗。 您如何解決 cljsbuild 錯誤?

[英]lein cljsbuild fails with untraceable error. How do you troubleshoot cljsbuild errors?

我沒有看到任何編譯日志文件,終端中的錯誤不足以讓我進一步排除故障。 我如何獲得更詳細的錯誤記錄,或者我應該如何解決這個問題?

下面堆棧跟蹤的前幾行

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/離合器“0.4.0”]

問題仍然是如何獲取 cljsbuild 的詳細/完整日志。

更新 2事實證明庫在依賴項列表中的位置會產生影響。 如果它出現在[com.cognitect/transit-clj "0.8.313"] 之前編譯失敗,否則它可以工作。

ClojureScript 中的配置選項沒有很好的文檔記錄。 克隆現有(工作)項目並從那里開始是最容易的。 我建議從cljs-template 項目開始,如下所示(請參閱自述文件):

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

您還可以關閉 figwheel 以在瀏覽器中查看結果:

> 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...
------------------------

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM