• There was a time when USB was unplugged and console.log() was used, the console.log (serial) buffer was filled and Espruino hanged... But as said, this was a while ago...

    There is something else you need to know: if you use a string variable with the module name in require(), such as

    var moduleName = "moduleName";
    var module = require(moduleName);
    

    instead of a string literal in require(), such as

    var module = require("moduleName");
    

    then the upload cannot (recursively) discover ***in the source code by string search for 'require("...")' the required modules and does not upload them into the cache (before uploading that particular source code); and when it comes to the runtime - the actual execution of the require(...) - Espruino cannot find the module in the cache and then tries to find it in THE (or A) connected SD card... But that error shows in a very distinctive error message about no (SD card) file system mounted where the module could be found...

    The option to use a variable instead of string literal for requiring a module and prevent loading of the module into the cache at upload time is intentional, because this allows to enable runtime/dynamic module selection, but it requires the module to be accessible in runtime available - mounted - file system.

    Again, have to make this point: Espruino/JavaScript is a totally different runtime concept! When for modules the cache concept is used, it does not mean that actual code (bytes of)(virtual) machine or source code is moved around (from cache space into execution space) - like from a file cache, as you have in, for example a PC operating system. The cache caches the object - like an interpreted/executed function definition, which is just referenced... nothing is moved around (like in virtual machine memory cache of objects of the virtual machine).

    For Espruino, this means that

    var moduleName = "moduleName";
    require(moduleName) === require("moduleName") // true
    

    shows that the things left and right of the === are one of the same thing: identical.

    What are the symptoms you get of this not starting correctly?

About

Avatar for allObjects @allObjects started