Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.

Repository from Github https://github.comAzure/azure-sdk-for-jsRepository from Github https://github.comAzure/azure-sdk-for-js

Import statement failed for @azure/identity javascript module

sahuroshan opened this issue · comments

  • Package Name:
  • @azure/identity
  • Package Version:
  • ^4.7.0
  • Operating system:
  • nodejs
    • version:
    • v20.18.0
  • browser
    • edge

Describe the bug
Error while creating instance of DefaultAzureCredential using @azure/identity module.

import statement - import { DefaultAzureCredential } from "@azure/identity";

code causing this error - const creds = new DefaultAzureCredential();

Error - "https://localhost:1339/DmsAzurePortalExtension/Content/5.1.0.0/Scripts/DmsV2/Wizards/OfflineBlobMigrationSettingsTabBase.js" as the following dependencies failed to load; ["@azure/identity" : {Error: Couldn't load "@azure/identity"; error code 500}];}];}];}];

Additional context
tsconfig -
{
"compileOnSave": true,
"compilerOptions": {
"alwaysStrict": true,
"moduleResolution": "node",
"baseUrl": "Client",
"composite": true,
"skipLibCheck": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": true,
"module": "amd",
"noEmitHelpers": true,
"noImplicitAny": true,
"noImplicitThis": true,
"outDir": "Output/Content/Scripts",
"paths": {
"": [
"
"
]
},
"removeComments": false,
"rootDir": "Client",
"sourceMap": true,
"target": "es5",
"lib": [
"dom",
"es2015.promise",
"es5",
"scripthost",
"es2016"
]
},
"include": [
"Client/**/",
"ForExport/
"
]
}

package.json-
{
"name": "dmsazureportalextension",
"version": "1.0.0",
"description": "dev scripts in script property",
"scripts": {
"refreshVSToken": "vsts-npm-auth -config .npmrc",
"restore": "ap restore",
"build": "ap build",
"serve": "ap serve",
"start": "ap start",
"watch": "ap watch",
"release": "ap release",
"lint": "ap lint"
},
"author": "Microsoft",
"license": "MIT",
"dependencies": {
"@azure/identity": "^4.7.0",
"@types/node": "^22.13.10"
}
}

@sahuroshan There seems to be a mismatch in the version of node you are using and the version of @types/node package. If you are using node v 20, please update the version of @types/node in package.json to support 20.0.0.

Additionally, you can verify if @azure/identity is actually installed in your environment. For this you can check your lock file. If it hasn't, run npm install @azure/identity on the command line. And check the exact error message and stack trace that you see.

You could also try running your code in a different environment or setup to see if the issue persists. This can help identify if the problem is specific to your current environment.

To provide more specific suggestions, it would be helpful to have the following information:

  • Exact Error Message: The full error message, including any stack trace or additional details.
  • Environment Details: Information about your development environment, including the operating system, Node.js version, and any other relevant details.
  • Reproduction Steps: Detailed steps to reproduce the issue, including any specific configurations or setups.

Hi @sahuroshan. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

Hi @sahuroshan, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!