简体   繁体   中英

“'cljsbuild' not a task”

using lein for clojure, attempting to use the clojurescript plugin. followed all readme.md install steps, project.clj has

  :dependencies [[org.clojure/clojure "1.7.0"]
                [org.clojure/clojurescript "0.0-3126"]]
  ;; lein-cljsbuild plugin to build a CLJS project  
  :plugins [[lein-cljsbuild "1.0.6"]]  
  :hooks [leiningen.cljsbuild]

I cannot seem to get lein to recognize the plugin and am not sure what is being the gremlin.

C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein cljsbuild once
'cljsbuild' is not a task. See 'lein help'.
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein compile
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein cljsbuild once
'cljsbuild' is not a task. See 'lein help'.
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein -v
Leiningen 2.5.1 on Java 1.8.0_51 Java HotSpot(TM) 64-Bit Server VM
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>

If you use lein new mies ... for getting the project file, and execute the command, the automatically generated project.clj file should be modified. This is an example that shows the change:

Before:

(defproject simple "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.122" :classifier "aot"
                  :exclusion [org.clojure/data.json]]
                 [org.clojure/data.json "0.2.6" :classifier "aot"]]
  :jvm-opts ^:replace ["-Xmx1g" "-server"]
  :plugins [[lein-npm "0.6.1"]]
  :npm {:dependencies [[source-map-support "0.3.2"]]}
  :source-paths ["src" "target/classes"]
  :clean-targets ["out" "release"]
  :target-path "target")

After

(defproject simple "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.122" :classifier "aot"
                  :exclusion [org.clojure/data.json]]
                 [org.clojure/data.json "0.2.6" :classifier "aot"]]

  :node-dependencies [[source-map-support "0.2.8"]]

  :jvm-opts ^:replace ["-Xmx1g" "-server"]

  :plugins [[lein-npm "0.6.1"] 
            [lein-cljsbuild "1.0.4"]]

  :npm {:dependencies [[source-map-support "0.3.2"]]}
  :source-paths ["src" "target/classes"]
  :clean-targets ["out" "release"]
  :target-path "target"

  :cljsbuild {
      :builds [{:id "simple"
                :source-paths ["src"]
                :compiler {
                    :main simple.core
                    :output-to "out/simple.js"
                    :output-dir "out"
                    :optimizations :none
                    :target :nodejs
                    :cache-analysis true
                    :source-map true}}]})

As you see, you need to add lein-cljsbuild plugins with build information. For further explanation, refer to http://www.mase.io/code/clojure/node/2015/01/24/getting-started-with-clojurecript-and-node/

If you don't want the change, just run ./scripts/build .

I think the problem is that your project.clj file is lacking a :cljsbuild stanza/key which defines the various parameters required to compile the clojurescript source files.

Have a look at Modern Clojurescript Tutorial for more details or you can check out my clojurescript file upload example to get an idea of how you can define :cljsbuild targets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM