我在我的打字项目(node@18.14.0, typescript@5.2.2, @types/node@20.6.5
)的index.ts
中有以下代码:
import { dlopen } from "node:process";
nodemon index.ts
成功运行(我的本地插件已加载并执行)
tsc
次失败,error TS2339: Property 'dlopen' does not exist on type 'Process'
次失败
我看了一下,发现dlopen
实际上不存在于node_modules/@types/node/process.d.ts
(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v18/process.d.ts)中,甚至不出现在整个局部和全局node_modules
中(进行了文本搜索).
我猜dlopen
一定以某种方式存在于NodeJS运行时中,这就是为什么nodemon index.ts
可以工作,但它的类型定义就是不存在.
我如何解决/解决该问题?