2013-07-31 43 views
3

我知道這是一個非常基本的問題,但很奇怪,我花了幾個小時後無法完成工作,我真的需要幫助。Sublime Linter/ReferenceError:窗口未定義?

  • OSX 10.8.4
  • 崇高的文本2版本2.0.2構建2221
  • 節點v0.10.15
  • jshint v2.1.7

其實,我乾淨安裝的崇高文本2只是爲了這個;只是崇高包裝控制已安裝。

首先,我準備了foo.js代碼:

function x(a, b) 
{ 
    return a + b 

res = x(10, 20) 
console.log("res = " + res); 

這導致:

$ jshint foo.js          
foo.js: line 3, col 17, Missing semicolon. 
foo.js: line 6, col 16, Missing semicolon. 
foo.js: line 2, col 1, Unmatched '{'. 

3 errors 

所以,jshint作品至今的簡單測試的預期。

我嘗試過很多事情,才能將其與崇高短絨工作,但沒有成功,我乾淨安裝的崇高的應用程序,然後跟着視頻教程:

https://tutsplus.com/lesson/sublime-linter/

看起來很容易,和崇高短絨似乎已成功安裝並自述文件在00:30以視頻節目的形式出現,但在我的情況下,在此之後,保存或任何從未觸發任何內容的內容。

嗯,我完全失去了。請指教。謝謝。

UPDATE:

我注意到所示sublimeText控制檯中的錯誤!

Traceback (most recent call last): 
    File "./SublimeLinter.py", line 431, in _update_view 
    File "./SublimeLinter.py", line 143, in run_once 
    File "./sublimelinter/modules/base_linter.py", line 291, in run 
    File "./sublimelinter/modules/javascript.py", line 72, in parse_errors 
ValueError: Error from jshint: /Users/ken/Library/Application Support/Sublime Text 2/Packages/SublimeLinter/sublimelinter/modules/libs/jshint/jshint.js:7881 
})(window) 
^
ReferenceError: window is not defined 
    at Object.require.util (/Users/ken/Library/Application Support/Sublime Text 2/Packages/SublimeLinter/sublimelinter/modules/libs/jshint/jshint.js:7881:4) 

編輯: OK,這似乎是錯誤,我應該先檢查有..

https://github.com/SublimeLinter/SublimeLinter/issues

回答

1

目前解決類似的問題:

這樣做的修補程序 - 在Linux安裝中 - 添加

global.window = {};

到文件頂部

~/.config/sublime-text-2/Packages/SublimeLinter/sublimelinter/modules/libs/jshint/jshint.js

對於Windows或OS/X安裝,您需要找到Sublime Text軟件包配置的位置。

+0

謝謝。我注意到了。 –

+0

是的,我這麼認爲 - 自己的鏈接最終將我帶入了該解決方案,但我想在此爲其他計算器用戶提供此鏈接。 – RSeidelsohn

0

對於那些仍然收到此錯誤,編輯JSHint configuration file並添加以下選項:

"jshint_options": { 
    "undef": true, 
    "unused": true, 
    "browser": true, /* Defines DOM globals such as window, navigator, FileReader, etc. */ 
    "jquery": true, /* OPTIONAL: globals exposed by jQuery */ 
    "devel": true, /* OPTIONAL: globals such as debugging, alert */ 
    "globals": { /* OPTIONAL: set others that aren't predefined by JSHint */ 
    "Modernizr": true 
    } 
} 

瞭解更多關於pre-defined JSHint global variables