Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Error: Can't resolve 'crypto' React

I installed the jsonwebtoken package and ever since I'm getting the following error on running the React app : enter image description here

I tried installing the crypto-browserify package but that too didn't resolve the issue.

like image 707
Srinil Khandwala Avatar asked Jan 22 '26 14:01

Srinil Khandwala


2 Answers

Try adding the following just after the devDependencies in your package.json

"devDependencies": {
    ...
},
"browser": {
    "crypto": false
}
like image 167
Sayak China Avatar answered Jan 24 '26 04:01

Sayak China


I was facing the same issue. I was trying to generate the keys on in React and was getting the same issue. Now the issue is resolved. Just follow the steps given in link https://github.com/ChainSafe/web3.js#troubleshooting-and-known-issues Also add these two in package.json

"dependencies": {
   "crypto": "npm:crypto-browserify",
   "stream": "npm:stream-browserify",
}
like image 20
Mohit Prajapati Avatar answered Jan 24 '26 04:01

Mohit Prajapati



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!