mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Use file:// url with dynamic import
This commit is contained in:
parent
233a1995b3
commit
a8d093bacd
@ -10,6 +10,7 @@ const clone = require("clone");
|
||||
const exec = require("@node-red/util").exec;
|
||||
const log = require("@node-red/util").log;
|
||||
const hooks = require("@node-red/util").hooks;
|
||||
const url = require("url");
|
||||
|
||||
const BUILTIN_MODULES = require('module').builtinModules;
|
||||
|
||||
@ -139,7 +140,8 @@ function importModule(module) {
|
||||
const externalModuleDir = getInstallDir();
|
||||
const moduleDir = path.join(externalModuleDir,"node_modules",module);
|
||||
// Import needs the full path to the module's main .js file
|
||||
const moduleFile = require.resolve(moduleDir);
|
||||
// It also needs to be a file:// url for Windows
|
||||
const moduleFile = url.pathToFileURL(require.resolve(moduleDir));
|
||||
return import(moduleFile);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user