我一直在尝试运行 eval 或从 repl 导入 esm 模块,但无法使其工作。我尝试了一些在互联网上找到的东西。例如:是否可以将 Typescript 导入到正在运行的 ts-node REPL 实例中?
不确定我错过了什么,我收到的错误是:
var a = await import("./test").then(x=>x)
//or
var a = await import("./test").then(x=>x)
//gives
//TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
Run Code Online (Sandbox Code Playgroud)
import * as test from './src/test';
//works but then when I try to use 'test' it gives
//SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import
Run Code Online (Sandbox Code Playgroud)
ts-node --esm -e "import * …Run Code Online (Sandbox Code Playgroud)