-
Notifications
You must be signed in to change notification settings - Fork 55
Can't resolve 'crypto' in react-oauth2-pkce #33
Comments
With webpack 5 you have to make "crypto" and "stream" available in the browser.
Adjust resolving in your webpack config.
Works on Node 14.x and 16.x |
My team received the same error late last week, which was after the fix for this issue was identified here. Is there a timeline during which this fix will be incorporated into the npm package to install other components as well? Thanks. |
Hi @gardner @t-knapp Question...May i know the exact file name(with extension) where we have to add this webpack config? Also can you please incorporate the fixes for the above issue into the NPM package as i am currently working on a project where this issue is becoming a roadblock for me...Thanks!!!! |
Hi @shiv0808, from my package.json
from my webpack.js config file
|
Hi @t-knapp , i am really not sure which webpack.js you are referring to.I have 2 of them in my application:
do let me know which one are u referring to..Thanks!! |
Please do not change some code in node_modules folders ever. This is where your depenencies are installed to. Please read about how to configure webpack in a prober way: https://webpack.js.org/configuration/ |
Thanks you very much for your effort @t-knapp :) ✌️ ..I have created a new file webpack.config.js as mentioned under that link and added the fallback as you mentioned above. But unfortunately the same error still persists for me...Not sure if my application is able to recognize the webpack.config.js file. Also need to ask about this line of code:
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\ssriv112\react-sso-code\node_modules\react-oauth2-pkce\dist' BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. If you want to include a polyfill, you need to: Thank you once again for your efforts.. :) |
Hi there! Could anyone give me any hint how to solve these error? |
I ran into the same issue. According to facebook/create-react-app#11756 it will be good if the library doesn't rely on nodejs polyfills.. |
My pullreqest will solve these problem, feel free to review changes or use fork https://github.com/christoph-bittmann/react-oauth2-pkce |
I have a React.js application which is part of an oAuth2 architecture and in order to get a token it uses Authorization Code + PKCE flow as explained here.
The issue is that when I try to run the app

npm start
I get the following error:I tried with the suggested approach at many places to add the following in my package.json after devDependencies:
but I still have the same issue. I am using Node.js 14.0.0
The text was updated successfully, but these errors were encountered: