Note that there are some explanatory texts on larger screens.

plurals
  1. POsocket.io-client breaks when running grunt build
    primarykey
    data
    text
    <p>I have a Yeoman <a href="https://github.com/yeoman/generator-webapp" rel="nofollow"><code>webapp</code></a> project, where I've added <a href="https://github.com/LearnBoost/socket.io-client" rel="nofollow"><code>socket.io-client</code></a> using <code>bower</code>.</p> <p>Everything works fine when I run the webapp with <code>grunt server</code>. But when I build it with <code>grunt build</code>, I get the following error:</p> <pre><code>Uncaught TypeError: Cannot call method 'push' of undefined </code></pre> <p>By enabling source maps in <code>Gruntfile.js</code> (<code>generateSourceMaps: true</code>), I managed to track down the source of the error in <strong><code>socket.io.js</code></strong>:</p> <pre><code>/** * Add the transport to your public io.transports array. * * @api private */ io.transports.push('websocket'); </code></pre> <p>What could make <code>io.transports</code> become <em>undefined</em> after running <code>grunt build</code>?</p> <p><strong>UPDATE:</strong></p> <p>Probably worth telling that I use RequireJS and it's configured like this:</p> <pre><code>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'; // ... }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload