由于generator-ko的jQuery错误,Gulp失败了默认任务

Zer*_*_IX 1 jquery knockout.js yeoman gulp

所以我试图在我的由Yeoman生成的Knockout应用程序上运行gulp generator-ko.

我已经克隆了我的回购(在我的Macbook上构建得很好)到我的Windows 10盒子.如果我运行gulp default我得到以下错误(完整输出):

[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)
Run Code Online (Sandbox Code Playgroud)

当我导航到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";
Run Code Online (Sandbox Code Playgroud)

如果我通过关闭它来解决这个outro.js问题,那么该文件只包含一个类似的问题:

}));
Run Code Online (Sandbox Code Playgroud)

这几乎可以证实我对它是如何构建的想法.

有任何想法吗?

And*_*llo 6

很多周围挖这个后,发现一个答案提交PRnenitiko.

这与OSX/Win环境中前向/后向斜杠目录分隔符的差异有关.

所以要修复它,slash = require('slash');在你的gulp文件中添加一个引用.然后pathname = slash(pathname);babelTranspile功能.