【问题标题】:TSLint is throwing 'error TS2459: Module '"@azure/core-tracing"' declares 'Span' locally, but it is not exported.' and other errorsTSLint 抛出 'error TS2459: Module '"@azure/core-tracing"' 在本地声明 'Span',但未导出。'和其他错误
【发布时间】:2021-05-25 13:05:37
【问题描述】:

我不知道从哪里开始修复此错误。输出并没有真正告诉我很多信息,只是听起来“@azure/ai-text-analytics”安装有问题。我已经npm uninstall了两次并重新安装了两次。它给出了同样的错误,所以我猜它不是安装?

我得到的完整错误:

node_modules/@azure/core-http/types/latest/src/createSpanLegacy.d.ts:1:10 - error TS2459: Module '"@azure/core-tracing"' declares 'Span' locally, but it is not exported.

1 import { Span } from "@azure/core-tracing";
           ~~~~

  node_modules/@azure/core-tracing/types/core-tracing.d.ts:6:10
    6 import { Span } from '@opentelemetry/api';
               ~~~~
    'Span' is declared here.

node_modules/@azure/core-http/types/latest/src/webResource.d.ts:9:23 - error TS2305: Module '"@azure/core-tracing"' has no exported member 'Context'.

9 import { SpanOptions, Context } from "@azure/core-tracing";
                        ~~~~~~~


Found 2 errors.

显然,这些文件都不是我自己的代码,所以我没有其他可以展示的东西。

【问题讨论】:

  • 同样的问题,你找到解决办法了吗?
  • 哦,不。抱歉我现在才看到这个。我确实从微软那里得到了帮助。问题出在我的 tsconfig.json 文件上。这是我现在拥有的:{“compilerOptions”:{“module”:“commonjs”,“esModuleInterop”:true,“target”:“es6”,“noImplicitAny”:true,“moduleResolution”:“node”,“ sourceMap": true, "outDir": "dist", "baseUrl": ".", "paths": { "": ["node_modules/"] } }, "include": [ "src/**/*"] }

标签: javascript node.js typescript express azure-ai


【解决方案1】:

我收到了有关 GitHub 支持的帮助。这是答案的link

我做了更多调试,看起来 TypeScript 编译器正在尝试在 node_modules 中构建 d.ts 文件,这导致构建失败。看起来使用 tsconfig.json 文件中的路径选项导致了这个问题,当我删除它时,使用 core-http@1.2.4 构建的项目就好了。

【讨论】:

    猜你喜欢
    • 2020-06-29
    • 1970-01-01
    • 2020-08-27
    • 2012-03-08
    • 2017-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    相关资源
    最近更新 更多