Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Error: Can't resolve 'url' in @azure\keyvault-secrets\dist-esm\keyvault-common\src #24415

Closed
swojit opened this issue Jan 9, 2023 · 5 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@swojit
Copy link

swojit commented Jan 9, 2023

  • @azure/keyvault-secrets:
  • ^4.6.0:
  • Windows 11 Enterprise 22H2:
  • nodejs
    • 19.3.0:
  • browser
    • Edge/108.0.1462.76 (Official build) (64-bit):
  • typescript
    • ^4.9.4:

Describe the bug
I see a webpack issue with React:

ERROR in ./node_modules/@azure/keyvault-secrets/dist-esm/keyvault-common/src/parseKeyvaultIdentifier.js 3:0-27

Module not found: Error: Can't resolve 'url' in '.\node_modules\@azure\keyvault-secrets\dist-esm\keyvault-common\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

To Reproduce
Steps to reproduce the behavior:

  1. Create a react app. npx create-react-app my-app --template typescript
  2. npm install @azure/identity
  3. npm install @azure/keyvault-secrets
  4. Here's my App.tsx:
import { useEffect } from 'react';

import { SecretClient } from "@azure/keyvault-secrets";
import { DefaultAzureCredential } from "@azure/identity";

async function main() {
  const credential = new DefaultAzureCredential();
  const keyVaultName: string = process.env["KEY_VAULT_NAME"] || "";
  const url: string = `https://{keyVaultName}.vault.azure.net`;

  const client = new SecretClient(url, credential);
  const secretName = "secretName";
  const secret: string = (await client.getSecret(secretName)).value || "";
  console.log("secret: ", secret);
}


function App() {
  useEffect(() => {
    async function mainCall() {
      await main();
    }
    mainCall();
  }, []);
  return (
    <p>Hello World</p>
  );
}

export default App;
  1. npm start

Expected behavior
No build errors

Additional context
Full logs as generated by npm start:

Starting the development server...
Failed to compile.

Module not found: Error: Can't resolve 'url' in 'D:\Repos\my-app\node_modules\@azure\keyvault-secrets\dist-esm\keyvault-common\src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }
ERROR in ./node_modules/@azure/keyvault-secrets/dist-esm/keyvault-common/src/parseKeyvaultIdentifier.js 3:0-27
Module not found: Error: Can't resolve 'url' in '.\node_modules\@azure\keyvault-secrets\dist-esm\keyvault-common\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

webpack compiled with 1 error
Files successfully emitted, waiting for typecheck results...
Issues checking in progress...
No issues found.

Potentially related #19913 #19836

@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 9, 2023
@jeremymeng
Copy link
Contributor

This may have been addressed by PR #24380 where url dependency was removed.

@jeremymeng jeremymeng added Client This issue points to a problem in the data-plane of the library. KeyVault labels Jan 10, 2023
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jan 10, 2023
@xirzec
Copy link
Member

xirzec commented Jan 11, 2023

@jeremymeng would re-shipping keyvault-common address this then?

@jeremymeng
Copy link
Contributor

@xirzec Looks that currently in the repo only keyvault-admin and keyvault-certificates depend on @azure/keyvault-common. Also not sure if we released any version yet after moving to package dependency of keyvault-common.

@timovv
Copy link
Member

timovv commented Jan 16, 2023

We haven't GAed any packages that depend on @azure/keyvault-common yet, so re-releasing it wouldn't affect anything -- we'd need to re-release the other packages. But if I understand correctly, this is an issue that would only crop up when building for the browser.

@swojit: it's worth nothing that the Key Vault service, and by extension our Key Vault libraries, do not support the browser due to CORS issues, so even if your example were to build, I wouldn't expect it to work. See here for more details: https://github.com/Azure/azure-sdk-for-js/blob/main/samples/cors/ts/README.md

@timovv
Copy link
Member

timovv commented Jan 24, 2023

Closing as the use case is not supported. If this issue crops up when bundling for Node, then we can revisit the issue. Thanks!

@timovv timovv closed this as completed Jan 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants