2012-12-17 34 views
5

我試圖構建一個requirejs/backbone/handlebars項目,並且我似乎在嘗試運行app.build.js時遇到此錯誤:require-handlebars-plugin構建錯誤 - ReferenceError:_未定義

Tracing dependencies for: main 
ReferenceError: _ is not defined 
In module tree: 
    main 
     cs 
     hbs 
      underscore 

ReferenceError: _ is not defined 
In module tree: 
    main 
     cs 
     hbs 
      underscore 

    at Object.eval (eval at <anonymous> (/usr/local/share/npm/lib/node_modules/requirejs/bin/r.js:13718:64)) 

該應用程序完美地工作,沒有錯誤,當沒有建立。如果重要,該項目的骨幹和下劃線包含在requirejs墊片中。我會發布整個源代碼,但它是一個內部系統,所以我不能。如果需要更多信息,我可以發佈。

謝謝!

+0

聽起來就像是沒有看到_.js – kennypu

+0

@ kennypu是的它不能,但我不知道爲什麼 - 它在瀏覽器中運行時看到它。 –

+0

骨幹需要Underscore,Underscore定義'_'。 –

回答

2

我有同樣的問題,這個工作對我來說 -

從您的RequireJS墊片下劃線。

你underscore.js文件的底部,略高於右括號和調用語句

然後,添加一個定義語句來正確地導出_

define(function(){ 
     return _; 
    }); 

}).call(this); 
+0

工作得很好!謝謝! –

+0

關於這是爲什麼的任何想法? – andyzinsser

相關問題