Skip to content

Running grunt serve:dist generates a "Error: Can't find variable: io" #1409

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
pihomeserver opened this issue Nov 6, 2015 · 7 comments
Closed
Labels

Comments

@pihomeserver
Copy link

Hello,
When i want to execute the command grunt serve:distall goes well until the browser opens and wants to display the main screen :

[Error] Error: Can't find variable: io
http://localhost:9000/app/app.fabb3a2e.js:1:14658
e@http://localhost:9000/app/vendor.63da8223.js:4:7563
http://localhost:9000/app/vendor.63da8223.js:4:5954
e@http://localhost:9000/app/vendor.63da8223.js:4:7563
http://localhost:9000/app/vendor.63da8223.js:4:8141
d@http://localhost:9000/app/vendor.63da8223.js:4:7189
e@http://localhost:9000/app/vendor.63da8223.js:4:7526
f@http://localhost:9000/app/vendor.63da8223.js:4:7651
http://localhost:9000/app/vendor.63da8223.js:4:29805
http://localhost:9000/app/vendor.63da8223.js:12:15389
ea@http://localhost:9000/app/vendor.63da8223.js:4:25629
q@http://localhost:9000/app/vendor.63da8223.js:4:19612
h@http://localhost:9000/app/vendor.63da8223.js:4:15720
http://localhost:9000/app/vendor.63da8223.js:4:15161
k@http://localhost:9000/app/vendor.63da8223.js:12:14734
http://localhost:9000/app/vendor.63da8223.js:12:15001
$broadcast@http://localhost:9000/app/vendor.63da8223.js:5:27229
http://localhost:9000/app/vendor.63da8223.js:12:10620
i@http://localhost:9000/app/vendor.63da8223.js:5:18271
http://localhost:9000/app/vendor.63da8223.js:5:18443
$eval@http://localhost:9000/app/vendor.63da8223.js:5:25848
$digest@http://localhost:9000/app/vendor.63da8223.js:5:24284
$apply@http://localhost:9000/app/vendor.63da8223.js:5:26135
f@http://localhost:9000/app/vendor.63da8223.js:5:1657
q@http://localhost:9000/app/vendor.63da8223.js:5:3500
onload@http://localhost:9000/app/vendor.63da8223.js:5:4043
    (fonction anonyme)
    (fonction anonyme)
    ea
    q
    h
    (fonction anonyme)
    k
    (fonction anonyme)
    $broadcast
    (fonction anonyme)
    i
    (fonction anonyme)
    $eval
    $digest
    $apply
    f
    q
    onload

My app opens by default the login screen without error. But once logged in, i have that error and can't do anything else.

I removed the Thing model, created few more but nothing is using socket.io more than what is generated by the generator.

Is there any way to debug that and find from where it comes from ?

@Awk34
Copy link
Member

Awk34 commented Nov 6, 2015

You're probably not including socket.io/socket.io.js. Make sure it's being served up.

@pihomeserver
Copy link
Author

It's included in app.js. It works well with grunt serve

var app = express();
var server = http.createServer(app);
var socketio = require('socket.io')(server, {
  serveClient: config.env !== 'production',
  path: '/socket.io-client'
});
require('./config/socketio')(socket);

Do i have to set some env variables or anything else when i use grunt serve:list?

@pihomeserver
Copy link
Author

One more time i took back the original Gruntfile.js and now it works so was my fault but do not know why. Any way it works thanks Awk34 !

@Awk34
Copy link
Member

Awk34 commented Nov 7, 2015

👍

@xeroxoid
Copy link

FYI in case there is any similarity to the solution posted here: #766 (comment)

@z34
Copy link

z34 commented Feb 3, 2017

Hey, I think I'm having this issue... here are some versions that may be relevant:

  • angular-fullstack-generator 3.7.6

  • node v6.9.5

  • npm 3.10.10

  • angular-socket-io#0.7.0

  • angular#1.5.11

When I run gulp serve everything works fine, but now running gulp build and pushing to heroku, I'm getting "ReferenceError: io is not defined" and don't know how to go about making sure my build referenced socket correctly. I see in the Heroku logs that, upon connecting to the site, socket events are registering, so I think it's fine on the server, but something I did must have changed where the file holding io is stored - I'm not sure... is there any direction you might be able to give me to go about solving this?

I came across the link @xeroxoid shared as well, but changing my index.html to reference that different location broke the site locally (the file was not in that location, so that must have been with a later version... though I think I saw that 0.7.0 is the latest, so maybe that's a different situation). It works locally as is, but just not when I build and push to Heroku.

EDIT: I think I may have had a process running in the background of terminal that, once I closed terminal and opened it again, gave me different outcomes locally. With the above versions locally, I still don't get an error, but socket doesn't actually work; I can add/update/remove an item, and where it had always triggered the function given in syncUpdates <ie. socket.syncUpdates('thing', this.things, (thing, things) => { console.log('does not get here anymore');>, now that function doesn't get called, but no error is thrown either. After building and pushing to Heroku, I get "ReferenceError: io is not defined" ... any help would be greatly appreciated - thank you.

@z34
Copy link

z34 commented Feb 3, 2017

I've installed nvm and tried going back to previous node versions and have still not gotten socket to update, so I'm not sure the version of node is related to the problem I'm experiencing... wondering now if recently updating gulp to a newer version caused gulp serve and gulp build to do things differently?

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

No branches or pull requests

4 participants