【问题标题】:@types/forge-apis/index.d.ts' is not a module@types/forge-apis/index.d.ts' 不是模块
【发布时间】:2020-01-18 01:17:51
【问题描述】:

从 @types/forge-apis 导入 AuthClientTwoLegged 类时,我总是收到错误消息

import { AuthClientTwoLegged} from 'forge-apis';

...

var oAuth2TwoLegged = new AuthClientTwoLegged(CLIENT_ID, CLIENT_SECRET, [
  'data:read',
  'data:write'
]);

类型在tsconfic.json中定义:

"types": ["forge-viewer", "forge-apis"]

【问题讨论】:

  • 您是否安装了@types/forge-apis 作为您的开发依赖项?
  • 是的,它是作为开发依赖安装的
  • 错误信息:Module not found: Error: Can't resolve 'forge-apis' in
  • 你的打字稿版本是什么? 2.0+ 还是...?

标签: typescript autodesk-forge


【解决方案1】:

确保您的项目配置正确:

  • 安装@types/forge-apis 作为开发依赖。
  • 使用 Typescript 2 及更高版本进行编译。
  • 您不需要在 tsconfig 中明确指定 forge-apis 作为其定义,与包同名。

请参阅此示例 repo here 以供参考,您可以看到它正在通过构建,因此您可以放心地将您的项目基于它。

【讨论】:

    猜你喜欢
    • 2018-12-07
    • 2022-12-16
    • 2019-04-18
    • 2017-02-07
    • 2017-11-09
    • 2018-12-05
    • 2018-11-10
    • 2020-02-23
    • 2017-01-09
    相关资源
    最近更新 更多