Local module not found error

Posted on
  • I selected a project folder and the modules folder was created there by IDE. I copied my scada.js folder into it.

    Require module in my js file.

    const ScadaJs = require("scada.js");
    

    And I've got a problem, that IDE search this module online instead of local folder.

    ERROR: getURL("https://www.espruino.com/modulesĀ­/scada.js.js") error : Not Found WARNING: [notify_warn] Module scada.js not found
    
  • @wolandec

    take a look at the specs and all the samples: none use any extension... - no .js or .min.js when loading from local sandbox modules folder. Check the setup of you IDE for the proper discover / lookup / search sequence.

    Just use

    const ScadaJs = require("scada");
    

    and pick a naming like const = scadaModule ... if it behaves like a module of const Scada = ... if it is a constructor / behaves like a class definition. This helps in your app's type safety / robustness. You can also come up with a notation of your own for type oriented suffixes, like ...M or ...Mod for modules. You may find similar as 'best practice' of implementation of ancient interpretative languages / language dialects - like some BASICs - that denoted a String variable by (required) appending of the dollar sign ($), such as let name$ =, or let count% = for integers. Even though these times are long gone, the concept is still useful... and can be reflected by providing adequate naming and using upper / lower casing.

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

Local module not found error

Posted by Avatar for wolandec @wolandec

Actions