簡體   English   中英

在嘗試運行簡單的hello world clojurescript的.js輸出時,“無法設置屬性未定義的錯誤”

[英]Getting “cannot set property Error of undefined” when trying to run the .js output of a simple hello world clojurescript

我正在編譯:

(ns example.hello)
(js/console.log "Hello from ClojureScript!")

使用此配置:

(defproject lein-cljsbuild-example "1.2.3"
  :plugins [[lein-cljsbuild "0.2.9"]]
  :cljsbuild {
    :builds [{
        :source-path "src-cljs"
        :compiler {
          :output-to "war/javascripts/mainz.js"  ; default: main.js in current directory
          ;:optimizations :simple
          :target :nodejs
          ;:pretty-print true
          }}]})

哪個輸出的文件太大而無法放在這里,但會出錯:

goog.debug.Error = function(opt_msg) {
                 ^
TypeError: Cannot set property 'Error' of undefined
    at Object.<anonymous> (/Users/myuser/Clojure/cljstest/war/javascripts/mainz.js:503:18)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

好吧,在您提供的項目配置中,您的:optimizations :simple子句被注釋掉了。 這意味着它不會有任何Google Closure優化,這意味着輸出JavaScript 不會在一個足夠的文件中,而是分成許多文件。 這也意味着您必須明確包含來自Google Closure庫的base.js

看起來這就是這里發生的事情,雖然可能還有其他事情......我實際上並不熟悉ClojureScript的node.js輸出。

通過重新安裝leiningen並進行干凈的構建解決了這個錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM