clojurescript找不到cljs.core.async.macros

时间:2013-11-04 14:25:28

标签: clojure clojurescript core.async

我在client.cljs文件中有以下代码:

(ns onn.client
    (:require [enfocus.core :as ef]
          [enfocus.effects :as effects]
          [enfocus.events :as events]
          [clojure.browser.repl :as repl]
          [goog.net.XhrIo :as xhr]
          [cljs.core.async :as async :refer [chan close!]])
    (:use-macros [enfocus.macros :only [deftemplate defsnippet defaction]])
    (:require-macros [cljs.core.async.macros :refer [go alt!]]
))
;....the actual code follows

项目文件如下所示:

(defproject onn "DEV-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://exampl.com/FIXME"
  :dependencies [[org.clojure/clojure "1.5.1"]
             [ring/ring-core "1.1.8"]
             [ring/ring-jetty-adapter "1.1.8"]
             [org.clojure/clojurescript "0.0-1820"]
             [org.clojure/core.async "0.1.0-SNAPSHOT"]
             [enfocus "2.0.0-SNAPSHOT"]]
  :plugins [[lein-cljsbuild "0.3.2"]
            [lein-ring "0.8.3"]]
  :cljsbuild {:builds [{:source-paths ["src"],
                    :compiler {:pretty-print true,
                               :output-to "resources/public/js/main.js",
                               :warnings true,
                               :optimizations :whitespace}}]}
  :ring {:handler onn.server/app :port 3000})

...编译时给出了这个错误:

Caused by: clojure.lang.ExceptionInfo: 
Could not locate cljs/core/async/macros__init.class or cljs/core/async/macros.clj 
on classpath:  at line 1 src/onn/client.cljs

请注意,我的代码是从这里复制的:https://github.com/Dimagog/AsyncGET/blob/master/cljs/app.cljs这个人的项目具有相同的依赖关系并且有效。

知道为什么吗?谢谢!

更新: 我的cljsbuild是自动的。重新启动cljsbuild后,它编译得很好。谢谢!

5 个答案:

答案 0 :(得分:6)

当我(错误地)在我:include-macros true的要求中使用cljs.core.async时出现此错误:

;; THROWS ERROR
(ns my-ns
  (:require [cljs.core.async :refer [<!] :include-macros true])
  (:require-macros [cljs.core.async.macros :refer [go]]))

删除它有效:

;; DOES NOT THROW ERROR
(ns my-ns
  (:require [cljs.core.async :refer [<!]])
  (:require-macros [cljs.core.async.macros :refer [go]]))

答案 1 :(得分:3)

您的project.clj文件似乎缺少AsyncGET项目使用的存储库。

:repositories { "sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/" }

答案 2 :(得分:1)

我也碰到了这个。运行lein cljsbuild clean启用cljsbuild以拉入库并成功构建。

答案 3 :(得分:0)

只有当您的错误与brepl ...

相关时

如果您尝试将此代码用于“标准”clojurescript brepl,首先需要将clojure宏代码评估到repl中,然后可以从brepl中获得异步宏。此外,您可以尝试在brepl上使用@ cemerick / austin工具进行交互式编码https://github.com/cemerick/austin

答案 4 :(得分:0)

cljsbuild在自动播放。重新启动cljsbuild后,它编译得很好

相关问题