Closed
Description
The Problem
We need to load ESM in VM by import
, but currently, we got the following error messages:
TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:34:9)
at evalmachine.<anonymous>:2:28
at evalmachine.<anonymous>:6:3
at Script.runInContext (vm.js:142:18)
at Script.runInNewContext (vm.js:147:17)
at main (file:///home/huan/git/huan/sidecar/src/dump/t.ts:44:38) {
code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING'
}
Related Issues
- Modules: Specify or infer module type for
new vm.Script
nodejs/node#27387 - Roadmap for stabilization of vm modules nodejs/node#37648
- importModuleDynamically for vm module is cached nodejs/node#36351
Investigation
We need to set NODE_OPTIONS=--experimental-vm-modules
to enable vm.SourceTextModule
.