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

Webpack 5 compatibility and crypto dependency #5598

Closed
rsudworth opened this issue Jan 20, 2023 · 6 comments
Closed

Webpack 5 compatibility and crypto dependency #5598

rsudworth opened this issue Jan 20, 2023 · 6 comments
Assignees
Labels
answered Question has received "first qualified response" msal-node Related to msal-node package Needs: Author Feedback Awaiting response from issue author no-issue-activity Issue author has not responded in 5 days public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@rsudworth
Copy link

Core Library

MSAL Node (@azure/msal-node)

Core Library Version

1.14.6

Wrapper Library

Not Applicable

Wrapper Library Version

None

Public or Confidential Client?

Public

Description

I'm using msal to manage authentication for embedded PowerBI reports in an MS Dynamics ecommerce solution (https://github.com/microsoft/Msdyn365.Commerce.Online). A recent upgrade to the dynamics code included a requirement for webpack 5, which has led to the build now failing as follows:

"message": "Module not found: Error: Can't resolve 'crypto' in 'E:\\source\\repos\\xxx-xxx-xxx\\node_modules\\@azure\\msal-node\\dist'\n\nBREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.\nThis is no longer the case. Verify if you need this module and configure a polyfill for it.\n\nIf you want to include a polyfill, you need to:\n\t- add a fallback 'resolve.fallback: { \"crypto\": require.resolve(\"crypto-browserify\") }'\n\t- install 'crypto-browserify'\nIf you don't want to include a polyfill, you can use an empty module like this:\n\tresolve.fallback: { \"crypto\": false }"

As I understand it, webpack 5 stopped including some common Node libraries liike crypto and the recommended solution is to add a polyfill, as described by the error message. Unfortunately, the webpack build and config for the solution is wrapped in custom build scripts that aren't available to the developer. Is there any other work around available? Or perhaps an update is due soon that moves away from relying on the crypto library?

Thanks.

MSAL Configuration

No response

Relevant Code Snippets

No response

Identity Provider

Azure AD / MSA

Source

External (Customer)

@rsudworth rsudworth added the question Customer is asking for a clarification, use case or information. label Jan 20, 2023
@ghost ghost added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Jan 20, 2023
@github-actions github-actions bot added msal-node Related to msal-node package public-client Issues regarding PublicClientApplications labels Jan 20, 2023
@ghost ghost assigned jo-arroyo Jan 20, 2023
@jo-arroyo
Copy link
Collaborator

@bgavrilMS for visibility

@ghost ghost added answered Question has received "first qualified response" Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Jan 20, 2023
@jo-arroyo jo-arroyo assigned bgavrilMS and unassigned jo-arroyo Jan 23, 2023
@bgavrilMS bgavrilMS removed their assignment Jan 24, 2023
@ghost
Copy link

ghost commented Jan 30, 2023

@rsudworth This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.

@bgavrilMS
Copy link
Member

Possible duplicate: #5602

@sameerag sameerag self-assigned this Jan 31, 2023
@ghost ghost closed this as completed Feb 8, 2023
@DxDen1004
Copy link

I do not understand why this issue is marked as "completed". Completed what? Where is the answer to the author's question (and many more people's question)? Where is the fix?

Three years later and still, creating a React Solution in Visual Studio 2022 Enterprise edition (and not just running create-react-app from the cli), will present you with a project that won't even start as soon as you install @azure/msal-node because of this "Module not found" error (which appears to me as quite different from the No Matching Export issue). How are we supposed to use msal with node? Is msal-node deprecated? Why it is not working as expected when installed on a freshly created project?

` "message": "Module not found: Error: Can't resolve 'crypto' in 'E:\source\repos\project_folder\node_modules@azure\msal-node\dist'

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: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'

If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }"`

If you try to follow the suggestion in the error message and edit the webpack config file to add the fallback, you will get tons and tons more "can't resolve" errors.

Should we just stop using this package?

@crysiscore
Copy link

im having the same issue @DxDen1004 . installing @azure/msal-node results in a compile error:
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: { "crypto": require.resolve("crypto-browserify") }'
  • install 'crypto-browserify'

If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }"`

If you try to follow the suggestion in the error message and edit the webpack config file to add the fallback, you will get tons and tons more "can't resolve" errors.

@SaraRavasio
Copy link

SaraRavasio commented Oct 16, 2023

i'm having a similar experience!

i first get an error for http and https.

image

after they're added in the resolve.fallback, i get this new error

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Question has received "first qualified response" msal-node Related to msal-node package Needs: Author Feedback Awaiting response from issue author no-issue-activity Issue author has not responded in 5 days public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

7 participants