Handle undefined default export when importing module

Fixes #4536
This commit is contained in:
Nick O'Leary 2024-01-22 16:54:51 +00:00
parent 5b096bfd5e
commit c24f05c2cd
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -315,7 +315,7 @@ module.exports = function(RED) {
var spec = module.module; var spec = module.module;
if (spec && (spec !== "")) { if (spec && (spec !== "")) {
moduleLoadPromises.push(RED.import(module.module).then(lib => { moduleLoadPromises.push(RED.import(module.module).then(lib => {
sandbox[vname] = lib.default; sandbox[vname] = lib.default || lib;
}).catch(err => { }).catch(err => {
node.error(RED._("function.error.moduleLoadError",{module:module.spec, error:err.toString()})) node.error(RED._("function.error.moduleLoadError",{module:module.spec, error:err.toString()}))
throw err; throw err;