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:
parent
12a25c37aa
commit
f7bd600715
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
|
const url = require("url");
|
||||||
const {events,i18n,log} = require("@node-red/util");
|
const {events,i18n,log} = require("@node-red/util");
|
||||||
|
|
||||||
var runtime;
|
var runtime;
|
||||||
@ -53,8 +54,8 @@ function requireModule(name) {
|
|||||||
function importModule(name) {
|
function importModule(name) {
|
||||||
var moduleInfo = require("./index").getModuleInfo(name);
|
var moduleInfo = require("./index").getModuleInfo(name);
|
||||||
if (moduleInfo && moduleInfo.path) {
|
if (moduleInfo && moduleInfo.path) {
|
||||||
var relPath = path.relative(__dirname, moduleInfo.path);
|
const moduleFile = url.pathToFileURL(require.resolve(moduleInfo.path));
|
||||||
return import(relPath);
|
return import(moduleFile);
|
||||||
} else {
|
} else {
|
||||||
// Require it here to avoid the circular dependency
|
// Require it here to avoid the circular dependency
|
||||||
return require("./externalModules").import(name);
|
return require("./externalModules").import(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user