Try adding the following just after the devDependencies in your package.json
"devDependencies": {
...
},
"browser": {
"crypto": false
}
Try installing crypto-browserify
package and see if that works. If you still see that error try deleting your node_modules folder and install all packages again.
For me installing crypto-browserify worked flawlessly. You can do this by running the command yarn add crypto-browserify or if you prefer you can install it by doing npm i crypto-browserify. This npm will install almost all dependencies of node.js crypto module, check what are avaliables and what are not in case you need more information.
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. I used this package to generate the keys and then updated my package.json with these packages.
"dependencies": {
"assert": "^2.0.0",
"buffer": "^6.0.3",
"crypto": "npm:crypto-browserify",
"crypto-browserify": "^3.12.0",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
"stream": "npm:stream-browserify",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"web3": "^1.6.1"
},
If you just want to decode JWTs in React, you can replace jsonwebtoken
with jwt-decode
, and then you don't have to worry about installing anything extra or editing package.json
to resolve the crypto
error.
npm i jwt-decode
import jwt_decode from 'jwt-decode'
let decoded = jwt_decode(token)
You can use old vezgo sdk version.
You can install it by doing
npm i vezgo-sdk-js@0.0.6
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.