Skip to content
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

io is not defined #2

Open
TrangNguyen opened this issue Feb 14, 2014 · 3 comments
Open

io is not defined #2

TrangNguyen opened this issue Feb 14, 2014 · 3 comments

Comments

@TrangNguyen
Copy link

Hi, could you help please. Your app works perfectly but when I tried to integrate with https://github.com/linnovate/mean I got this error "io is not defined", which is listed here linnovate/mean#272. Your app and mean.io structurally is from the app by Madhums, that's why I thought it should be easy to switch. Mean.io uses swig as template engine to allow html.
When I start server, socket.io server side started but client side is not connected properly (?) because it does not do anything.
Any hint greatly appreciated.
Trang

@jlmonteagudo
Copy link
Owner

Hello Trang,

The socket.io connection in this demo is very simple, because it's using the default parameters.

The client is configured at line 6 of this file: https://github.com/jlmonteagudo/voteExpress/blob/master/public/js/services/socketio.js

This is the code: var socket = io.connect();

The server is configured at line 3 of this file:
https://github.com/jlmonteagudo/voteExpress/blob/master/config/socket-io.js

This is the code: var socketIO = require('socket.io').listen(server);

I don't know why you aren't getting connected; have you checked your browser console to see if there is any error? have you checked your browser Network tab to see what URLs is trying to connect socket.io?

@TrangNguyen
Copy link
Author

Hi, thanx for reply.
I have no error on browser console. All scripts loaded as expected from localhost:3000 but nothing happens. I added to socket-io.js a console.log on 'connection' to check but it does not execute. I set log level to 3 and all it console to terminal is 'info - socket.io started'. It's jslint that said 'io is not defined' on the service Socket.
I tried different order of loading the front end scripts too but it remains the same. I can't figure out what 'io is not defined' mean.

@jackhsu978
Copy link

@TrangNguyen
Similar to how AngularJS creates a global variable angular, socket.io on the client-side creates a global variable io. However, jshint does not know it is a global variable and thought it is undefined. To fix this, include io as one of the globals in .jshintrc like this:

    "globals": { // Globals variables.
        "angular": true,
        "io": true
    },

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

3 participants