How to use the @node-red/registry.addModule function in @node-red/registry

To help you get started, we’ve selected a few @node-red/registry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sakazuki / node-red-desktop / src / main / node-red.ts View on Github external
private async addModule(pkgname: string) {
    try {
      const info: {nodes: any} = await registry.addModule(pkgname);
      RED.runtime.events.emit("runtime-event", {
        id: "node/added",
        payload: info.nodes,
        retain: false
      });
    } catch (err) {
      if (err.code === "module_already_loaded") {
        this.error(err, `${pkgname} already loaded`);
        return;
      }
      if (err.code !== "MODULE_NOT_FOUND") throw err;
      this.success(`${pkgname} installed`);
    }
  }