0

This is an angular app. Im using bower and require.js:

bower install

install requirejs#2.3.3

socket.io-client: 1.7.2
angular-socket-io: 0.7.0

When running

grunt serve         

I see this error in the browser console:

Error: Mismatched anonymous define() module: function (){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t,e){"object"===("undefined"==typeof t?"undefined":i(t))&&(e=t,t=void 0),e=e||{};var r,n=s(t),a=n.source,p=n.id,f=n.path,l=h[p]&&f in h[p].nsps,d=e.forceNew||e["force new connection"]||!1===e.multiplex||l;return d?(u("ignoring socket cache for %s",a),r=c(a,e)):(h[p]||(u("new io instance for %s",a),h[p]=c(a,e)),r=h[p]),n.query&&!e.query?e.query=n.query:e&&"object"===i(e.query)&&(e.query=o(e.query)),r.socket(n.path,e)}function o(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symb    

It seems to me it is some kind of incompatibility between require.js and socket.io/angular-socket.io version. I read something here:

https://github.com/socketio/socket.io-client/issues/690

where somebody seemed to have the same issue. But I could not really understand if they found out some solution to the issue.

oderfla
  • 1,695
  • 4
  • 24
  • 49
  • If this is meant to be browser code, then perhaps socket.io-client is the wrong module. – jfriend00 Apr 24 '17 at 14:44
  • What do you maen? Yse, it is browser code. Im trying to use socket io on the client to connect to server. What do you mean by "is the wrong module"? Should I use something else? And what in that case? – oderfla Apr 24 '17 at 14:49
  • What I meant is that one uses `socket.io-client` when you want to make a socket.io client connection from a node.js server. You use the regular socket.io module from a browser. – jfriend00 Apr 24 '17 at 17:29
  • so what should i do? What do you suggest? Im still not sure I undestand your point. – oderfla Apr 24 '17 at 18:36
  • The library meant for running in the browser is called `socket.io`, not `socket.io-client`. – jfriend00 Apr 24 '17 at 23:55
  • Areyou really sure? Most of resources I find says you should use socket.io-client on client side. – oderfla Apr 25 '17 at 07:58

0 Answers0