"io is not defined"
See original GitHub issueHi,
I’m trying to integrate the mean stack (linnovate) with socket.io and I got this error " io is not defined". The issue is also referenced here https://github.com/linnovate/mean/issues/272.
//server.js
var server = require('http').createServer(app);
var io = require('socket.io').listen(server, {
'log level': 2
});
io.sockets.on('connection', function(socket) {
console.log('Client Connected');
}); //<<<<<< 'socket' is defined but never used (linting error)
...
server.listen(port);
//public/js/services/socket.js
angular.module('mean.socket').factory('socket', ['$rootScope', function ($rootScope) {
var socket = io.connect();
return {
... // like Brian Ford did
}
}]);
// app/views/includes/foot.html which feeds into the index.html
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/js/services/socket.js"></script>
// public/js/app.js
angular.module('mean', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles', 'mean.socket']);
angular.module('mean.socket', []);
This is the error
Linting server.js ...ERROR
[L56:C44] W098: 'socket' is defined but never used.
io.sockets.on('connection', function(socket) {
Linting public/js/services/socket.js ...ERROR
[L4:C18] W117: 'io' is not defined.
var socket = io.connect();
I don’t know what I am missing. I have no error consoled to the browser, socket.io.js is loaded properly, socket.io starts server side but nothing works. I have tried to give specific url to io.connect(), load socket.io.js from cdn but it doesn’t change. ‘io is not defined’, what does it mean, any help, any hint greatly appreciated. Trang
Issue Analytics
- State:
- Created 10 years ago
- Comments:17
Top Results From Across the Web
socket.io - ReferenceError: io is not defined - Stack Overflow
I tried it in Chrome, and it's giving me an Uncaught ReferenceError: require is not defined for the socket.io.js file. So I decide...
Read more >Step.9 Uncaught ReferenceError: io is not defined at main.js:45
The first error shows that the /socket.io/socket.io.js did not load. As a result, io is not defined and fails. Did you run "npm...
Read more >iOS : socket.io - ReferenceError: io is not defined - YouTube
iOS : socket.io - ReferenceError: io is not defined [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] iOS : socket.io ...
Read more >Advanced Node and Express: ReferenceError: io is not defined
After looking at this SO discussion, I replaced "socket.io": "~2.3.0" in the package.json file with "@types/socket.io": "~2.3.0" . However ...
Read more >NameError: name 'io' is not defined - Coding - PsychoPy
In the console I get this error “NameError: name 'io' is not defined”. What specifically went wrong when you tried that?:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can also tell JSHint that io is a global variable. it recognizes this comment notation and won’t bother warning you that io isn’t being defined in your service (which it doesn’t need to be since it’s global) just put this before your module declaration at the top of your factory service
/* globals io */ angular.module(…
You’re a bot, no?
Why do you reply to a 7 year old thread with no meaningful reply whatsoever?