MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.25k stars 21.42k forks source link

Getting 'Module '"@azure/core-tracing"' declares 'Span' locally, but it is not exported.' error #75845

Closed JeffMII closed 3 years ago

JeffMII commented 3 years ago

I am learning the Azure AI Text Analytics API, and I've ran into a problem. The application is an Express app using Typescript. Here is the full error:

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.

None of these files are my code so I don't really know what else I can share here. I have tried reinstalling the package twice using npm uninstall @azure/ai-text-analytics and npm install @azure/ai-text-analytics because it seemed to me that the error may have come from a bad install, but I still get the error.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

femsulu commented 3 years ago

Thanks for bringing this to our attention. We are actively investigating and will get back to you soon.

GiftA-MSFT commented 3 years ago

Hello @JeffMII can you please share the Microsoft document you are referencing? We need to link the document to your post. Thanks.

Sintrias commented 3 years ago

Hello @JeffMII can you please share the Microsoft document you are referencing? We need to link the document to your post. Thanks.

I'm not sure if I understand exactly what you're asking for. Here is the link to the Azure Text Analytics documentation I used to get the app started:

https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/quickstarts/client-libraries-rest-api?pivots=programming-language-javascript&tabs=version-3-1#sentiment-analysis

Note that there has obviously been a recent update to the node package '@azure/ai-text-analytics' because in a separate learning project I did a couple months ago, the package I installed then is working fine in the current project. I simply copied the package from the old node_modules directory to the current node_modules directory and it works. So the problem isn't in any code I've written.

GiftA-MSFT commented 3 years ago

@aahill can you please review above feedback. Are you aware of any changes that may cause the error?

GiftA-MSFT commented 3 years ago

@Sintrias just to verify, did you specify the version as well? npm install --save @azure/ai-text-analytics@5.1.0-beta.5

Sintrias commented 3 years ago

@Sintrias just to verify, did you specify the version as well? npm install --save @azure/ai-text-analytics@5.1.0-beta.5

I did not. The command I used to install the package is npm install @azure/ai-text-analytics.

As far as I understand, this installs the latest version of a package.

GiftA-MSFT commented 3 years ago

Tried both and unable to reproduce the error.

GiftA-MSFT commented 3 years ago

Are you getting this error when you try to install the package or getting the error from a specific section of the code?

Sintrias commented 3 years ago

I can share my project with you. It is a work in progress though, so it doesn't fully compile even with the previous package version. It did however reach the next build stage after changing to the previous package version.

Sintrias commented 3 years ago

Are you getting this error when you try to install the package or getting the error from a specific section of the code?

When doing npm run start. It is an Express project. Installing the package has no problems. I get the errors when trying to run the project using the above.

Sintrias commented 3 years ago

Also, I am using TSLint.

GiftA-MSFT commented 3 years ago

Upon further review, the issue seems to be based on the modules you are importing and the way you are importing them. I found a similar question that may help point you in the right direction. Also, checkout this thread. Hope it helps.

deyaaeldeen commented 3 years ago

Hi @Sintrias. I work on the @azure/ai-text-analytics package and I hope to be able to help resolving the issue you are seeing. If non of what my colleagues' suggestions worked, would you mind sharing a github repo to your Express project so I can take a closer look?

Sintrias commented 3 years ago

Upon further review, the issue seems to be based on the modules you are importing and the way you are importing them. I found a similar question that may help point you in the right direction. Also, checkout this thread. Hope it helps.

Ah. Those links are handling Angular projects. I'm very familiar with Angular. Neither of those will fix the issue however. NgModule is only recognized by Angular. The project I'm working on now is an Express project so NgModule won't be helpful here.

Sintrias commented 3 years ago

Hi @Sintrias. I work on the @azure/ai-text-analytics package and I hope to be able to help resolving the issue you are seeing. If non of what my colleagues' suggestions worked, would you mind sharing a github repo to your Express project so I can take a closer look?

I can. It's pretty late in the day at the moment so I will need to wait for tomorrow to share it with you. I'll be sure to create the repo first thing in the morning and share the pull request link with you.

deyaaeldeen commented 3 years ago

@Sintrias no worries at all, I am looking forward to it!

Sintrias commented 3 years ago

@Sintrias no worries at all, I am looking forward to it!

Hey sorry. I haven't had the time to create the repo yet today. Just letting you know I haven't forgotten. I should have it by the end of the day.

JeffMII commented 3 years ago

So I just realized I'm using two of my accounts here. Sorry if anyone had some confusion. I created the github repo:

https://github.com/JeffMII/Azure-Text-Analytics-Debug.git

Just keep in mind that the app is still in progress so it doesn't compile even with the old '@azure/ai-text-analytics'. But, the error keeping me from progressing is the one we're discussing here. Thanks for the help.

JeffMII commented 3 years ago

I have updated the repo with code that fully compiles when using the previous version of ai-text-analytics. The error still happens with the latest version.

JeffMII commented 3 years ago

I'm not able to find the version number for the package that works. Can someone tell me what the last version number is so I can include it in my package.json? Thanks.

JeffMII commented 3 years ago

As I can tell, this is the update that's causing issues:

\node_modules\@azure\core-http\CHANGELOG.md

1.2.4 (2021-03-30)

  • Rewrote bearerTokenAuthenticationPolicy to use a new backend that refreshes tokens only when they're about to expire and not multiple times before. This fixes the issue: 13369.
JeffMII commented 3 years ago

How can I get my package.json to specify the version that does not include the update to this part of the package?

Sintrias commented 3 years ago

Any updates?

deyaaeldeen commented 3 years ago

Hi @Sintrias, thanks a lot for providing the github repo!

How can I get my package.json to specify the version that does not include the update to this part of the package?

I just tried and it seems like @azure/core-http@1.2.3 works fine so I think you can try npm install @azure/core-http@1.2.3 --save to install it.

I opened this issue to track why @azure/core-http@1.2.4 causes a build failure in text analytics: https://github.com/Azure/azure-sdk-for-js/issues/15494.

Thanks for your patience! Please let me know if there is anything we can do to help!

Also, did you look into using our most recent beta package? You can try it by npm install @azure/ai-text-analytics@5.1.0-beta.6 --save.

Sintrias commented 3 years ago

Thanks @deyaaeldeen I will give that a shot once I get back to my laptop. I'll let you know how it goes.

deyaaeldeen commented 3 years ago

@Sintrias I did more debugging and it looks like the TypeScript compiler is trying to build the d.ts files inside node_modules which is causing the build failure. Looks like using the paths option in your tsconfig.json file caused this issue and when I removed it, the project built just fine with core-http@1.2.4. I hope that helps!

Sintrias commented 3 years ago

@Sintrias I did more debugging and it looks like the TypeScript compiler is trying to build the d.ts files inside node_modules which is causing the build failure. Looks like using the paths option in your tsconfig.json file caused this issue and when I removed it, the project built just fine with core-http@1.2.4. I hope that helps!

That did it! Nice. Thanks for the help. Weird though that I didn't have the same issue with the previous version.

deyaaeldeen commented 3 years ago

I am glad that worked!

@GiftA-MSFT please close this issue now that it has been resolved.

aahill commented 3 years ago

please-close