运行grunt生成时socket.io-client中断

运行grunt生成时socket.io-client中断,socket.io,requirejs,gruntjs,yeoman,Socket.io,Requirejs,Gruntjs,Yeoman,我有一个约曼项目,我使用bower添加了这个项目 当我使用grunt服务器运行webapp时,一切正常。但是,当我使用grunt build构建它时,我得到以下错误: Uncaught TypeError: Cannot call method 'push' of undefined 通过在Gruntfile.js(generateSourceMaps:true)中启用源代码映射,我成功地在socket.io.js中找到了错误的来源: /** * Add the transport to y

我有一个约曼项目,我使用
bower
添加了这个项目

当我使用
grunt服务器运行webapp时,一切正常。但是,当我使用
grunt build
构建它时,我得到以下错误:

Uncaught TypeError: Cannot call method 'push' of undefined
通过在
Gruntfile.js
generateSourceMaps:true
)中启用源代码映射,我成功地在
socket.io.js
中找到了错误的来源:

/**
 * Add the transport to your public io.transports array.
 *
 * @api private
 */

io.transports.push('websocket');
运行
grunt build
后,什么会使
io.transport
变得未定义

更新:

可能值得一提的是,我使用的是RequireJS,其配置如下:

require.config({
    paths: {
        jquery: '../bower_components/jquery/jquery',
        // ...
        // socket.io: Try the node server first
        'socket.io': ['/socket.io/socket.io', '../bower_components/socket.io-client/dist/socket.io'],
    },
    shim: {
        // Export io object: https://gist.github.com/guerrerocarlos/3651490
        'socket.io': {
            exports: 'io'
        }
    }
});

require(['jquery', 'socket.io'], function ($, io) {
    'use strict';
    // ...
});

您应该只在以下路径中定义socket.io-client:

paths: {
    'jquery': '../bower_components/jquery/jquery',
    'socket.io': '../bower_components/socket.io-client/dist/socket.io'
},
此外,不应设置io参数(它是全局设置的)(或使用其他类似sio的方法)

require(['jquery', 'socket.io'], function ($) {
    'use strict';
    // ...
});