我打开cljsbuild的详细程度试图了解发生了什么,我第一次看到这个时就运行了lein cljsbuild:
$ lein cljsbuild once
Compiling ClojureScript.
Compiling "resources/public/js/app.js" from ("src/cljs" "src/cljc" "env/dev/cljs")...
... lots of output ....
Successfully compiled "resources/public/js/app.js" in 13.321 seconds.
Compiling "target/js/server-side.js" from ["src/cljs" "src/cljc" "src/node"]...
Analyzing jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/core.cljs
Analyzing jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/core.cljs
Applying optimizations :simple to 12 sources
Successfully compiled "target/js/server-side.js" in 16.043 seconds.
请注意,它表示正在优化12个来源。当我再次运行它时,只需要进行一些小改动就可以重新编译target / js / server-side.js,就会发生这种情况:
$ lein cljsbuild once
Compiling ClojureScript.
Compiling "target/js/server-side.js" from ["src/cljs" "src/cljc" "src/node"]...
Analyzing jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/core.cljs
Analyzing jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/core.cljs
Applying optimizations :simple to 13 sources
Sep 16, 2015 11:29:22 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: cljs.nodejs:1: ERROR - namespace "cljs.nodejs" cannot be provided twice
goog.provide('cljs.nodejs');
^
Sep 16, 2015 11:29:22 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 1 error(s), 0 warning(s)
ERROR: JSC_DUPLICATE_NAMESPACE_ERROR. namespace "cljs.nodejs" cannot be provided twice at cljs.nodejs line 1 : 0
Successfully compiled "target/js/server-side.js" in 11.125 seconds.
那么它现在怎么说它正在优化13个来源和繁荣!它失败。有什么想法吗?
进入一些细节,我的project.clj看起来像这样:
(defproject projectx "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[ring-server "0.4.0"]
[cljsjs/react "0.13.3-1"]
[reagent "0.5.1"]
[reagent-forms "0.5.9"]
[reagent-utils "0.1.5"]
[ring "1.4.0"]
[ring/ring-defaults "0.1.5"]
[prone "0.8.2"]
[compojure "1.4.0"]
[hiccup "1.0.5"]
[environ "1.0.1"]
[org.clojure/clojurescript "1.7.122" :scope "provided"]
[bidi "1.21.0"]
[kibu/pushy "0.3.3"]
[aleph "0.4.0"]]
:plugins [[lein-environ "1.0.0"]
[lein-asset-minifier "0.2.2"]
[lein-npm "0.6.1"]]
:ring {:handler projectx.handler/app
:uberwar-name "projectx.war"}
:min-lein-version "2.5.0"
:uberjar-name "projectx.jar"
:main projectx.server
:clean-targets ^{:protect false} [:target-path
[:cljsbuild :builds :app :compiler :output-dir]
[:cljsbuild :builds :app :compiler :output-to]]
:source-paths ["src/clj" "src/cljc"]
:minify-assets {:assets {"resources/public/css/site.min.css" "resources/public/css/site.css"}}
:cljsbuild {:builds {:app {:source-paths ["src/cljs" "src/cljc"]
:compiler {:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/app"
:main "projectx.dev"
:verbose true}}
:server-side {:source-paths ["src/cljs" "src/cljc" "src/node"]
:compiler {:output-to "target/js/server-side.js"
:output-dir "target/js/server-side"
:target :nodejs
:main "projectx.node"
:optimizations :simple
:verbose true}}}}
:npm {:dependencies [[xmlhttprequest "1.7.0"]
[express "4.13.3"]]}
:profiles {:dev {:repl-options {:init-ns projectx.repl}
:dependencies [[ring/ring-mock "0.3.0"]
[ring/ring-devel "1.4.0"]
[lein-figwheel "0.3.9"]
[org.clojure/tools.nrepl "0.2.11"]
[pjstadig/humane-test-output "0.7.0"]]
:source-paths ["env/dev/clj"]
:plugins [[lein-figwheel "0.3.9"]
[lein-cljsbuild "1.0.6"]]
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]
:figwheel {:http-server-root "public"
:server-port 3449
:nrepl-port 7002
:css-dirs ["resources/public/css"]
:ring-handler projectx.handler/app}
:env {:dev true}
:cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]
:compiler {:optimizations :none
:source-map true
:pretty-print true}}
:server-side {:compiler {:optimizations :simple
:source-map "target/js/server-side.js.map"
:pretty-print true}}}}}
:uberjar {:hooks [leiningen.cljsbuild minify-assets.plugin/hooks]
:env {:production true}
:aot :all
:omit-source true
:cljsbuild {:jar true
:builds {:app {:source-paths ["env/prod/cljs"]
:compiler {:optimizations :advanced
:pretty-print false}}
:server-side {:compiler {:optimizations :advanced
:pretty-print false}}}}}})
这些都是我项目中goog.provide('cljs.nodejs')的所有提及:
$ grep -R "goog.provide('cljs.nodejs')" .
./target/js/server-side/B616C7F.js:goog.provide('cljs.nodejs');
./target/js/server-side/cljs/nodejs.js:goog.provide('cljs.nodejs');
./target/js/server-side/D2E353E.js:goog.provide('cljs.nodejs');
projectx.node,包含在服务器端但不包含应用程序的文件包含:
(ns projectx.node
(:require [cljs.nodejs]))
(cljs.nodejs/enable-util-print!)
(defn -main [& args]
(println "NodeJS!!!"))
(set! *main-cli-fn* -main)
如果我从此文件中删除了nodejs的提及,或者我删除了:target :nodejs
,那么问题就会消失(但我与NodeJS的兼容性也是如此)。
如果它有用,CLASSPATH包含:
/Users/pupeno/Projects/clojure/projectx/test
/Users/pupeno/Projects/clojure/projectx/env/dev/clj
/Users/pupeno/Projects/clojure/projectx/src/clj
/Users/pupeno/Projects/clojure/projectx/src/cljc
/Users/pupeno/Projects/clojure/projectx/dev-resources
/Users/pupeno/Projects/clojure/projectx/resources
/Users/pupeno/Projects/clojure/projectx/target/classes
/Users/pupeno/.m2/repository/digest/digest/1.4.4/digest-1.4.4.jar
/Users/pupeno/.m2/repository/org/apache/maven/maven-model-builder/3.0.4/maven-model-builder-3.0.4.jar
/Users/pupeno/.m2/repository/org/apache/maven/maven-repository-metadata/3.0.4/maven-repository-metadata-3.0.4.jar
/Users/pupeno/.m2/repository/clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.jar
/Users/pupeno/.m2/repository/org/clojure/tools.namespace/0.2.10/tools.namespace-0.2.10.jar
/Users/pupeno/.m2/repository/org/apache/maven/wagon/wagon-provider-api/2.2/wagon-provider-api-2.2.jar
/Users/pupeno/.m2/repository/org/apache/maven/wagon/wagon-http/2.2/wagon-http-2.2.jar
/Users/pupeno/.m2/repository/org/clojure/tools.reader/0.10.0-alpha3/tools.reader-0.10.0-alpha3.jar
/Users/pupeno/.m2/repository/org/eclipse/jetty/jetty-http/9.2.10.v20150310/jetty-http-9.2.10.v20150310.jar
/Users/pupeno/.m2/repository/ring/ring-mock/0.3.0/ring-mock-0.3.0.jar
/Users/pupeno/.m2/repository/instaparse/instaparse/1.4.0/instaparse-1.4.0.jar
/Users/pupeno/.m2/repository/prismatic/schema/0.4.3/schema-0.4.3.jar
/Users/pupeno/.m2/repository/watchtower/watchtower/0.1.1/watchtower-0.1.1.jar
/Users/pupeno/.m2/repository/http-kit/http-kit/2.1.18/http-kit-2.1.18.jar
/Users/pupeno/.m2/repository/org/ow2/asm/asm-all/4.1/asm-all-4.1.jar
/Users/pupeno/.m2/repository/org/sonatype/aether/aether-impl/1.13.1/aether-impl-1.13.1.jar
/Users/pupeno/.m2/repository/org/clojure/data.priority-map/0.0.2/data.priority-map-0.0.2.jar
/Users/pupeno/.m2/repository/manifold/manifold/0.1.0/manifold-0.1.0.jar
/Users/pupeno/.m2/repository/org/eclipse/jetty/jetty-server/9.2.10.v20150310/jetty-server-9.2.10.v20150310.jar
/Users/pupeno/.m2/repository/org/clojure/tools.macro/0.1.5/tools.macro-0.1.5.jar
/Users/pupeno/.m2/repository/clj-tuple/clj-tuple/0.2.1/clj-tuple-0.2.1.jar
/Users/pupeno/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
/Users/pupeno/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
/Users/pupeno/.m2/repository/org/apache/httpcomponents/httpcore/4.1.2/httpcore-4.1.2.jar
/Users/pupeno/.m2/repository/org/clojure/core.memoize/0.5.6/core.memoize-0.5.6.jar
/Users/pupeno/.m2/repository/ring/ring-ssl/0.2.1/ring-ssl-0.2.1.jar
/Users/pupeno/.m2/repository/ring/ring-headers/0.1.3/ring-headers-0.1.3.jar
/Users/pupeno/.m2/repository/ring/ring-codec/1.0.0/ring-codec-1.0.0.jar
/Users/pupeno/.m2/repository/ring/ring-servlet/1.4.0/ring-servlet-1.4.0.jar
/Users/pupeno/.m2/repository/org/clojure/core.cache/0.6.3/core.cache-0.6.3.jar
/Users/pupeno/.m2/repository/org/jsoup/jsoup/1.6.1/jsoup-1.6.1.jar
/Users/pupeno/.m2/repository/clj-time/clj-time/0.9.0/clj-time-0.9.0.jar
/Users/pupeno/.m2/repository/org/apache/httpcomponents/httpclient/4.1.2/httpclient-4.1.2.jar
/Users/pupeno/.m2/repository/lein-figwheel/lein-figwheel/0.3.9/lein-figwheel-0.3.9.jar
/Users/pupeno/.m2/repository/org/sonatype/sisu/sisu-guice/3.0.3/sisu-guice-3.0.3-no_aop.jar
/Users/pupeno/.m2/repository/kibu/pushy/0.3.3/pushy-0.3.3.jar
/Users/pupeno/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4.jar
/Users/pupeno/.m2/repository/org/clojure/core.async/0.1.346.0-17112a-alpha/core.async-0.1.346.0-17112a-alpha.jar
/Users/pupeno/.m2/repository/reagent/reagent/0.5.1/reagent-0.5.1.jar
/Users/pupeno/.m2/repository/ring/ring-devel/1.4.0/ring-devel-1.4.0.jar
/Users/pupeno/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
/Users/pupeno/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20150805-acd8b553/google-closure-library-third-party-0.0-20150805-acd8b553.jar
/Users/pupeno/.m2/repository/com/cemerick/pomegranate/0.3.0/pomegranate-0.3.0.jar
/Users/pupeno/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar
/Users/pupeno/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.2.3/sisu-inject-bean-2.2.3.jar
/Users/pupeno/.m2/repository/cljsjs/react/0.13.3-1/react-0.13.3-1.jar
/Users/pupeno/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar
/Users/pupeno/.m2/repository/org/clojure/tools.analyzer.jvm/0.1.0-beta12/tools.analyzer.jvm-0.1.0-beta12.jar
/Users/pupeno/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
/Users/pupeno/.m2/repository/crypto-equality/crypto-equality/1.0.0/crypto-equality-1.0.0.jar
/Users/pupeno/.m2/repository/org/apache/maven/maven-aether-provider/3.0.4/maven-aether-provider-3.0.4.jar
/Users/pupeno/.m2/repository/ring/ring-jetty-adapter/1.4.0/ring-jetty-adapter-1.4.0.jar
/Users/pupeno/.m2/repository/org/sonatype/aether/aether-connector-wagon/1.13.1/aether-connector-wagon-1.13.1.jar
/Users/pupeno/.m2/repository/com/cemerick/clojurescript.test/0.0.4/clojurescript.test-0.0.4.jar
/Users/pupeno/.m2/repository/org/sonatype/sisu/sisu-inject-plexus/2.2.3/sisu-inject-plexus-2.2.3.jar
/Users/pupeno/.m2/repository/org/apache/maven/wagon/wagon-http-shared4/2.2/wagon-http-shared4-2.2.jar
/Users/pupeno/.m2/repository/org/clojure/tools.nrepl/0.2.11/tools.nrepl-0.2.11.jar
/Users/pupeno/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
/Users/pupeno/.m2/repository/args4j/args4j/2.0.26/args4j-2.0.26.jar
/Users/pupeno/.m2/repository/hiccup/hiccup/1.0.5/hiccup-1.0.5.jar
/Users/pupeno/.m2/repository/ring-server/ring-server/0.4.0/ring-server-0.4.0.jar
/Users/pupeno/.m2/repository/com/cemerick/url/0.1.1/url-0.1.1.jar
/Users/pupeno/.m2/repository/environ/environ/1.0.1/environ-1.0.1.jar
/Users/pupeno/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar
/Users/pupeno/.m2/repository/ring-refresh/ring-refresh/0.1.2/ring-refresh-0.1.2.jar
/Users/pupeno/.m2/repository/org/clojure/tools.logging/0.3.1/tools.logging-0.3.1.jar
/Users/pupeno/.m2/repository/pathetic/pathetic/0.5.0/pathetic-0.5.0.jar
/Users/pupeno/.m2/repository/figwheel-sidecar/figwheel-sidecar/0.3.9/figwheel-sidecar-0.3.9.jar
/Users/pupeno/.m2/repository/org/eclipse/jetty/jetty-io/9.2.10.v20150310/jetty-io-9.2.10.v20150310.jar
/Users/pupeno/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar
/Users/pupeno/.m2/repository/com/cemerick/piggieback/0.1.5/piggieback-0.1.5.jar
/Users/pupeno/.m2/repository/ring/ring-core/1.4.0/ring-core-1.4.0.jar
/Users/pupeno/.m2/repository/org/tcrawley/dynapath/0.2.3/dynapath-0.2.3.jar
/Users/pupeno/.m2/repository/org/clojure/java.classpath/0.2.2/java.classpath-0.2.2.jar
/Users/pupeno/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
/Users/pupeno/.m2/repository/clj-stacktrace/clj-stacktrace/0.2.8/clj-stacktrace-0.2.8.jar
/Users/pupeno/.m2/repository/pjstadig/humane-test-output/0.7.0/humane-test-output-0.7.0.jar
/Users/pupeno/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
/Users/pupeno/.m2/repository/aleph/aleph/0.4.0/aleph-0.4.0.jar
/Users/pupeno/.m2/repository/compojure/compojure/1.4.0/compojure-1.4.0.jar
/Users/pupeno/.m2/repository/com/google/javascript/closure-compiler/v20150729/closure-compiler-v20150729.jar
/Users/pupeno/.m2/repository/com/google/javascript/closure-compiler-externs/v20150729/closure-compiler-externs-v20150729.jar
/Users/pupeno/.m2/repository/ring/ring-anti-forgery/1.0.0/ring-anti-forgery-1.0.0.jar
/Users/pupeno/.m2/repository/riddley/riddley/0.1.9/riddley-0.1.9.jar
/Users/pupeno/.m2/repository/org/clojure/google-closure-library/0.0-20150805-acd8b553/google-closure-library-0.0-20150805-acd8b553.jar
/Users/pupeno/.m2/repository/org/apache/maven/maven-model/3.0.4/maven-model-3.0.4.jar
/Users/pupeno/.m2/repository/primitive-math/primitive-math/0.1.4/primitive-math-0.1.4.jar
/Users/pupeno/.m2/repository/potemkin/potemkin/0.3.13/potemkin-0.3.13.jar
/Users/pupeno/.m2/repository/org/clojure/tools.analyzer/0.1.0-beta12/tools.analyzer-0.1.0-beta12.jar
/Users/pupeno/.m2/repository/ring/ring/1.4.0/ring-1.4.0.jar
/Users/pupeno/.m2/repository/byte-streams/byte-streams/0.2.0/byte-streams-0.2.0.jar
/Users/pupeno/.m2/repository/ns-tracker/ns-tracker/0.3.0/ns-tracker-0.3.0.jar
/Users/pupeno/.m2/repository/medley/medley/0.6.0/medley-0.6.0.jar
/Users/pupeno/.m2/repository/org/mozilla/rhino/1.7R5/rhino-1.7R5.jar
/Users/pupeno/.m2/repository/crypto-random/crypto-random/1.2.0/crypto-random-1.2.0.jar
/Users/pupeno/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar
/Users/pupeno/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
/Users/pupeno/.m2/repository/prone/prone/0.8.2/prone-0.8.2.jar
/Users/pupeno/.m2/repository/org/sonatype/aether/aether-api/1.13.1/aether-api-1.13.1.jar
/Users/pupeno/.m2/repository/io/netty/netty-all/4.1.0.Beta4/netty-all-4.1.0.Beta4.jar
/Users/pupeno/.m2/repository/reagent-forms/reagent-forms/0.5.9/reagent-forms-0.5.9.jar
/Users/pupeno/.m2/repository/clojurescript-build/clojurescript-build/0.1.9/clojurescript-build-0.1.9.jar
/Users/pupeno/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar
/Users/pupeno/.m2/repository/ring/ring-defaults/0.1.5/ring-defaults-0.1.5.jar
/Users/pupeno/.m2/repository/reagent-utils/reagent-utils/0.1.5/reagent-utils-0.1.5.jar
/Users/pupeno/.m2/repository/joda-time/joda-time/2.6/joda-time-2.6.jar
/Users/pupeno/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar
/Users/pupeno/.m2/repository/commons-fileupload/commons-fileupload/1.3.1/commons-fileupload-1.3.1.jar
/Users/pupeno/.m2/repository/org/eclipse/jetty/jetty-util/9.2.10.v20150310/jetty-util-9.2.10.v20150310.jar
/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar
/Users/pupeno/.m2/repository/ring-cors/ring-cors/0.1.7/ring-cors-0.1.7.jar
/Users/pupeno/.m2/repository/io/aleph/dirigiste/0.1.0/dirigiste-0.1.0.jar
/Users/pupeno/.m2/repository/clout/clout/2.1.2/clout-2.1.2.jar
/Users/pupeno/.m2/repository/org/sonatype/aether/aether-connector-file/1.13.1/aether-connector-file-1.13.1.jar
/Users/pupeno/.m2/repository/org/sonatype/aether/aether-spi/1.13.1/aether-spi-1.13.1.jar
/Users/pupeno/.m2/repository/figwheel/figwheel/0.3.9/figwheel-0.3.9.jar
/Users/pupeno/.m2/repository/bidi/bidi/1.21.0/bidi-1.21.0.jar
答案 0 :(得分:0)
到目前为止,我确信这是一个错误:http://dev.clojure.org/jira/browse/CLJS-1452
进一步调查显示ClojureScript 1.7.107和1.7.122会发生这种情况,但1.7.48或1.7.132则不然。