Skip to content

io undefined after deploy to heroku #766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jordanbaucke opened this issue Jan 5, 2015 · 10 comments
Closed

io undefined after deploy to heroku #766

jordanbaucke opened this issue Jan 5, 2015 · 10 comments

Comments

@jordanbaucke
Copy link

I went ahead and re-ran the generator with a clean app. just to see if there was anything I could pick-out that I might have changed in the configuration, however, aside from uncommenting the 'Auth' module like so:

angular.module('myApp')
    .factory('socket', function(socketFactory, Auth) {

        // socket.io now auto-configures its connection when we ommit a connection url
        var ioSocket = io('', {
            // Send auth token on connection, you will need to DI the Auth service above
            'query': 'token=' + Auth.getToken(),
            path: '/socket.io-client'
        });

        var socket = socketFactory({
            ioSocket: ioSocket
        });

grunt build & grunt buildcontrol:heroku run normally without errors?

However when I load the app in Heroku I still get:

ReferenceError: io is not defined
@Tazer
Copy link

Tazer commented Jan 16, 2015

I'm having the same problem when running grunt serve:dist .

I do see that in the code there is a config for serveClient , it gets set to false when production. But even if i set it to true, it doesnt work .. the code work fine with "grunt serve"

@jordanbaucke
Copy link
Author

@Tazer ok good I was starting to think I was the only one...hmmm

@camcim
Copy link

camcim commented Feb 8, 2015

Same my end. I'm able to grunt serve however I get the above mentioned io error when deployed to heroku

@fergalmoran
Copy link

What was the solution here, I'm still seeing this, need to set serveClient: true in production.

//edit: turns out I was using a higher version of socket.io-client - brought that back to 1.0.6 and it works now!

@Awk34
Copy link
Member

Awk34 commented Oct 17, 2016

Closed due to inactivity

@Awk34 Awk34 closed this as completed Oct 17, 2016
@xeroxoid
Copy link

Hi, just to inform everyone who may face this issue, the problem for me was that newer versions of socket.io-client contain the file within dist, rather than the root directory (as in previous versions).

Thus, in index.html you would have to change the line:

<script src="socket.io-client/socket.io.js"></script>

to

<script src="socket.io-client/dist/socket.io.js"></script>

and the bundler will then package it correctly into xx.vendor.js

This came up when I remove the node_modules folder and freshly installed all the packages.

@LuxDie
Copy link

LuxDie commented Mar 17, 2017

Hey, I'm having this issue with version 3.8 of the generator.

I've tried xeroxoid solution but the socket library is still not getting inside vendor.js. I've also tried installing the bower version and pointing to it, like so: <script src="bower_components/socket.io-client/dist/socket.io.js"></script>, to no avail.
This happens with a new project out of the box after running gulp serve:dist.

Any idea why?

Configuration is: babel, jade, sass, ui-router, bootstrap, ui-bootstrap, mongoose, auth(google, fb), socket.io, gulp, mocha

@WasimAhmad
Copy link

Have same issue here... I am working on a project using [email protected] and having issue on gulp serve:dist
ReferenceError: io is undefined.
gulp serve is working good..
how to fix it???

@WasimAhmad
Copy link

for now @xeroxoid solution worked..

@WasimAhmad
Copy link

to work for both production and development search and update path for
socket.io-client
as
socket.io-client/dist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants