2015-10-18 62 views
0

所以我試圖運行由Yeoman generator-ko生成的Knockout應用程序的吞噬。Gulp由於發生器ko的jQuery錯誤而失敗的默認任務

我克隆了我的回購(在我的Macbook上構建的很好)到我的Windows 10盒子。如果我運行一飲而盡默認我得到以下錯誤(全光輸出):

[14:33:41] Using gulpfile ~\Documents\GitHub\TMPrototype\Gulpfile.js 
[14:33:41] Starting 'html'... 
[14:33:41] Starting 'js:babel'... 
[14:33:41] Starting 'css'... 
[14:33:41] Finished 'html' after 46 ms 
[14:33:41] Finished 'css' after 198 ms 
[BABEL] Note: The code generator has deoptimised the styling of "src/bower_modules/knockout/dist/knockout.debug.js" as it exceeds the max of "100KB". 
[BABEL] Note: The code generator has deoptimised the styling of "src/bower_modules/jquery/dist/jquery.js" as it exceeds the max of "100KB". 
stream.js:94 
     throw er; // Unhandled stream error in pipe. 
      ^
SyntaxError: src/bower_modules/jquery/src/intro.js: Unexpected token (45:0) 
    43 | // you try to trace through "use strict" call chains. (#13335) 
    44 | //"use strict"; 
> 45 | 
    |^
    at Parser.pp.raise (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\location.js:24:13) 
    at Parser.pp.unexpected (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\util.js:82:8) 
    at Parser.pp.parseExprAtom (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\expression.js:425:12) 
    at Parser.parseExprAtom (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\plugins\jsx\index.js:412:22) 
Process terminated with code 8. 
    at Parser.pp.parseExprSubscripts (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\expression.js:236:19) 
    at Parser.pp.parseMaybeUnary (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\expression.js:217:19) 
    at Parser.pp.parseExprOps (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\expression.js:163:19) 
    at Parser.pp.parseMaybeConditional (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\expression.js:145:19) 
    at Parser.pp.parseMaybeAssign (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\expression.js:112:19) 
    at Parser.pp.parseExpression (C:\Users\Andrew\Documents\GitHub\TMPrototype\node_modules\babel-core\node_modules\babylon\lib\parser\expression.js:79:19) 

當我瀏覽到bower_modules/jquery/src/intro.js參數功能未關閉。起初,我認爲這只是通過在後面傳遞其餘代碼來編譯的方式。

的jQuery/src目錄/ intro.js(注意它是如何不關閉)

(function(global, factory) { 

    if (typeof module === "object" && typeof module.exports === "object") { 
     // For CommonJS and CommonJS-like environments where a proper `window` 
     // is present, execute the factory and get jQuery. 
     // For environments that do not have a `window` with a `document` 
     // (such as Node.js), expose a factory as module.exports. 
     // This accentuates the need for the creation of a real `window`. 
     // e.g. var jQuery = require("jquery")(window); 
     // See ticket #14549 for more info. 
     module.exports = global.document ? 
      factory(global, true) : 
      function(w) { 
       if (!w.document) { 
        throw new Error("jQuery requires a window with a document"); 
       } 
       return factory(w); 
      }; 
    } else { 
     factory(global); 
    } 

// Pass this if window is not defined yet 
}(typeof window !== "undefined" ? window : this, function(window, noGlobal) { 

// Support: Firefox 18+ 
// Can't be in strict mode, several libs including ASP.NET trace 
// the stack via arguments.caller.callee and Firefox dies if 
// you try to trace through "use strict" call chains. (#13335) 
//"use strict"; 

如果我解決,通過關閉它,outro.js也有類似的問題,該文件只包含:

})); 

這幾乎證實了我對它是如何構建的想法。

任何想法?

+0

今天有同樣的問題。你有沒有運氣? –

+0

@AndreGallo不好意思,雖然令人難以置信的令人沮喪。我正在考慮在這方面給予獎勵。 –

+0

@Jezzabeans它似乎是一個環境問題。該發生器在我的Macbook Pro(OSX El capitan)上運行正常,但在我的Windows 10 VM上失敗。如果我發現潛在的問題是什麼,我會發佈一個答案... –

回答

4

經過大量的挖掘後,找到了答案PR submittednenitiko

這是關於在OSX/Win環境中正向/反向斜槓目錄分隔符的區別。

所以要解決它,請在您的gulp文件中添加對slash = require('slash');的引用。然後pathname = slash(pathname);babelTranspile函數。

+0

謝謝安德烈,一旦我回家,我會測試這個。 –

+0

經過測試,它工作得很好,謝謝你找到這個安德烈。享受賞金。編輯:只能在10小時內獎勵它。 –

+0

你簡直就是人間的神哈哈!非常感謝您對此進行調試。 – pimbrouwers

相關問題