我有一个示例typscript项目,它是我从github克隆的,并随npm install一起安装。
在index.ts中,我正在尝试导入第三方模块(https://github.com/ScatterCo/Depthkit.js)。此模块已使用npm install depthkit
下载到node_modules文件夹中
为了导入模块,我尝试了import {DepthKit} from 'depthkit/build/depthkit';
或import * as DK from 'depthkit/build/depthkit';
但是当我运行var depthkit = new DepthKit();
或var depthkit = new DK.DepthKit();
时,我得到了一个错误的Uncaught TypeError: depthkit_1.DepthKit is not a constructor
我该怎么解决这个问题?
发布于 2021-11-10 18:22:30
根据我读到的代码,正确的导入应该是import DepthKit from "depthkit"
,因为DepthKit类是索引默认导出
https://stackoverflow.com/questions/69913899
复制相似问题