2016-08-24 3 views
0

私はcljsで幽霊(0.12.0)を使用するのに苦労しています。おそらく、nsを適切に設定していないでしょう。簡単な例を実行ClojureScriptでSpecterを使用するには?

私は、次のエラーメッセージが出ます:

=> (select [:a :b] {:a {:b 42}}) 
#object[TypeError TypeError: Cannot read property 'specter' of undefined] 

私のNSは次のようになります。

(ns dummy.core 
    (:require [com.rpl.specter :as s]) 
    (:require-macros [com.rpl.specter.macros :refer [select]])) 

編集

これは、実際のブラウザで動作します。

しかし、それは私がそれを最初に試したfigwheelのREPLにはありません。

マイproject.clj(やや簡略化のために短縮)

(defproject dummy "0.1.0-SNAPSHOT" 
    :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"] 
       [org.clojure/clojurescript "1.7.228" :scope "provided"] 
       [reagent "0.5.1"] 
       [com.rpl/specter "0.12.0"]] 

    :plugins [[lein-cljsbuild "1.1.1"]] 
    :min-lein-version "2.5.0" 
    :clean-targets ^{:protect false} 
    [:target-path 
     [:cljsbuild :builds :app :compiler :output-dir] 
     [:cljsbuild :builds :app :compiler :output-to]] 

    :resource-paths ["public"] 

    :cljsbuild {:builds {:app {:source-paths ["src"] 
          :figwheel {:on-jsload dummy.core/fig-reload} 
          :compiler {:main dummy.core 
             :output-to "public/js/app.js" 
             :output-dir "public/js/out" 
             :source-map-timestamp true 
             :asset-path "/js/out" 
             :optimizations :none 
             :pretty-print true}} 

         :min {:source-paths ["src"] 
          :compiler {:main dummy.core 
             :output-to "public/js/app.js" 
             :optimizations :whitespace}}}} 

    :figwheel { :http-server-root "public" 
       :server-port 3449 
       :nrepl-port 7002 
       :nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"] 
       :css-dirs ["public/css"]} 

    :profiles { :dev { :dependencies [[prone "1.0.2"] 
            [lein-doo "0.1.6"] 
            [pjstadig/humane-test-output "0.7.1"] 
            [lein-figwheel "0.5.0-6"] 
            [org.clojure/tools.nrepl "0.2.12"] 
            [com.cemerick/piggieback "0.2.1"]] 

        :plugins [[lein-figwheel "0.5.0-6"] 
           [lein-doo "0.1.6"]] 

        :doo {:build "test"} 

        :injections [(require 'pjstadig.humane-test-output) 
            (pjstadig.humane-test-output/activate!)]}}) 
+0

あなたの 'project.clj'ファイルはどのように見えますか? – n2o

答えて

2

FWIW私は幽霊がclojurescriptに行くが、今で正常に動作するようになっ道路バンプのカップルを持っていました。道路の隆起は、2つの名前空間を引き込み、どのスペーサーのビットがどの名前空間にあるかを調べることにありました。ネイサンマルツは、彼がunify them eventuallyに望んでいると述べたが、それまで私の名前空間は、次のようになります。あなたへ

(ns test.core 
    (:require [com.rpl.specter :as sp]) 
    (:require-macros [com.rpl.specter.macros :refer [select setval] :as spm])) 

だから、その異なりません!しかし、少なくともあなたの名前空間を除外できるように見えます。これはfigwheelでも私のためにうまくいく、btw。私はlein new devcards test経由でDevcardsを出発点として使用し、そこからproject.cljを使用しました。

関連する問題