我在index.ts
中的Typescript项目([[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection) , [[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection) , @types/ [[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)
)中有以下代码:
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
工作,但它的类型定义不存在。
如何解决/解决这个问题?
1条答案
按热度按时间noj0wjuj1#
您可以尝试在项目中为
dlopen
函数添加新的本地types.d.ts
声明文件:字符串