简体   繁体   English

lein cljsbuild 因无法追踪的错误而失败。 您如何解决 cljsbuild 错误?

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

I do not see any log file for the compilation and the error in the terminal is insufficient for me to troubleshoot further.我没有看到任何编译日志文件,终端中的错误不足以让我进一步排除故障。 How do i get more verbose error logging or how should i trouble shoot this issue?我如何获得更详细的错误记录,或者我应该如何解决这个问题?

First few lines from stacktrace below下面堆栈跟踪的前几行

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)

I have a simple cljs file with the following contents我有一个包含以下内容的简单 cljs 文件

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

My project.clj has the following config for cljsbuild我的 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"]

Update 1 Following Alan's advice below, i created a new template and narrowed down the cause to adding a fairly old library for interacting with CouchDB更新 1按照下面 Alan 的建议,我创建了一个新模板并将原因缩小到添加一个相当旧的库以与 CouchDB 交互

[com.ashafa/clutch "0.4.0"] [com.ashafa/离合器“0.4.0”]

The question remains how do I get detailed/complete logs for cljsbuild.问题仍然是如何获取 cljsbuild 的详细/完整日志。

Update 2 Turns out the position of the library in the list of dependencies has an impact.更新 2事实证明库在依赖项列表中的位置会产生影响。 If it appears before [com.cognitect/transit-clj "0.8.313"] compilation fails otherwise it works.如果它出现在[com.cognitect/transit-clj "0.8.313"] 之前编译失败,否则它可以工作。

The configuration options in ClojureScript are not well documented. ClojureScript 中的配置选项没有很好的文档记录。 It is easiest to clone an existing (working) project and go from there.克隆现有(工作)项目并从那里开始是最容易的。 I would suggest starting from the cljs-template project as follows (see the README):我建议从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

At this point your project has the npm stuff needed for the unit tests.此时,您的项目具有单元测试所需的 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

You can also fire off figwheel to see results in the browser:您还可以关闭 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