首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >lein cljsbuild因无法跟踪错误而失败。如何排除cljsbuild错误?

lein cljsbuild因无法跟踪错误而失败。如何排除cljsbuild错误?
EN

Stack Overflow用户
提问于 2019-02-12 23:23:57
回答 1查看 290关注 0票数 1

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

下面堆栈跟踪的前几行

代码语言:javascript
复制
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文件,包含以下内容

代码语言:javascript
复制
(ns moose.core)   
(defn run []
  (.write js/document "This is not the end!"))

我的project.clj有下面的cljsbuild配置

代码语言:javascript
复制
: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的建议,我创建了一个新模板,并缩小了添加一个用于与CouchDB交互的相当老的库的范围

[com.ashafa/离合器"0.4.0"]

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

更新2结果显示库在依赖项列表中的位置有影响。如果它出现在[com.relitect/transit "0.8.313"]编译失败之前,否则它会工作。

EN

回答 1

Stack Overflow用户

发布于 2019-02-13 00:14:43

ClojureScript中的配置选项没有很好的文档说明。克隆一个现有的(正在工作的)项目并从那里开始是最容易的。我建议从cljs-模板项目开始,如下(参见自述):

代码语言:javascript
复制
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材料。

代码语言:javascript
复制
> 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以查看结果:

代码语言:javascript
复制
> 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...
------------------------
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54660202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档