sbstjn / noduino

JavaScript and Node.js Framework for controlling Arduino with HTML and WebSockets
http://sbstjn.github.io/noduino/
1.23k stars 232 forks source link

Uncaught ReferenceError: io is not defined:- Noduino.Socket.js:54 #35

Closed brookemitchell closed 6 years ago

brookemitchell commented 9 years ago

Once the example web server is running, when I click on 'Connect to Arduino' I get this error. Unfortunately my debug skills aren't quite there yet. Any help?

pandafulmanda commented 9 years ago

Hi! I think I had this same problem. This might be happening because the socket io is being asked to connect before the io is attached on the window.

It helped me to move the following line to the end of the views/layout.jade file:

  script(data-main="scripts/app." + jsApp, type="text/javascript", src="scripts/vendor/require-jquery.js")

This is so that the scripts loading definitely should happen after the socket io script runs in the head. You can see this here: https://github.com/pandafulmanda/noduino/blob/2707b6420869d95d1fba07dfec88c84f72243569/views/layout.jade .

I hope that helps!

hems commented 6 years ago

if that's the case ( your script needs to wait ) you can add a very ugly attribute to the script tag defer=true and keep it on the head and it will be loaded after the ones without the defer property. ugly but works, better avoid it!