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
double post :-(
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.
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.
const = scadaModule ...
const Scada = ...
let name$ =
let count% =
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem