1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix importing external module from node-red module

This commit is contained in:
Nick O'Leary 2022-04-21 15:06:08 +01:00
parent 12a25c37aa
commit f7bd600715
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -16,6 +16,7 @@
const path = require("path");
const semver = require("semver");
const url = require("url");
const {events,i18n,log} = require("@node-red/util");
var runtime;
@ -53,8 +54,8 @@ function requireModule(name) {
function importModule(name) {
var moduleInfo = require("./index").getModuleInfo(name);
if (moduleInfo && moduleInfo.path) {
var relPath = path.relative(__dirname, moduleInfo.path);
return import(relPath);
const moduleFile = url.pathToFileURL(require.resolve(moduleInfo.path));
return import(moduleFile);
} else {
// Require it here to avoid the circular dependency
return require("./externalModules").import(name);