MQTT Module Bug

Posted on
  • Trying to load MQTT on ESP8266/Espruino reports an error. Here is what I put in the IDE:

    var mqtt = require("MQTT").create("192.168.1.10");

    when I try to upload this script I get:

    Uncaught Error: Both arguments to addCached must be strings
    at line 9 col 201
    ...t,a);a.connect();return a}});

                              ^
    

    WARNING: Module "MQTT" not found
    Uncaught Error: Field or method "create" does not already exist, and can't create it on undefined
    at line 1 col 27
    var mqtt = require("MQTT").create("192.168.1.10");

                          ^
    

    =undefined


    I opened to see where the error is, and it definitely reports on something inside MQTT.min.js . Please help.

    Thanks,
    Jordan

  • Are you entering this in the right hand side and uploading?

    I think you might be doing this on the left hand side of the ide.

    The module needs to be uploaded first - there's the module not found...

  • I am entering it on the right side.
    Actually, I can see the text of the error inside MQTT.min.js, line 9 col 201:
    "...t,a);a.connect();return a}});"

    Obviously it finds the module, tries to load it and because of syntax errors it fails to load it. Then in my code it reports that the module cannot be found:
    var mqtt = require("MQTT").create("192.168.1.10");

    Please try it if you can.

  • Sounds like you turned on Modules uploaded as functions (BETA) in the Web IDE. Turn it off, or use cutting edge build, and you'll be fine.

    It'd be worth turning off everything marked as BETA in settings - especially the NPM one

  • Thank you, Gordon. That worked.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

MQTT Module Bug

Posted by Avatar for user70979 @user70979

Actions