1

I have created a react app, when I try npm run, I am getting this error:

ERROR in ./node_modules/@toruslabs/eccrypto/browser.js 9:17-34

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

Dependencies in package.json looks like this:

  "dependencies": {
    "@project-serum/anchor": "^0.24.2",
    "@solana-mobile/wallet-adapter-mobile": "^0.9.0",
    "@solana/wallet-adapter-base": "^0.9.13",
    "@solana/wallet-adapter-react": "^0.15.15",
    "@solana/wallet-adapter-react-ui": "^0.9.13",
    "@solana/wallet-adapter-wallets": "^0.18.2",
    "@solana/web3.js": "^1.53.0",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.1.1",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.0.0",
    "react-scripts": "5.0.1",
    "stream": "^0.0.2",
    "web-vitals": "^2.1.4"
  },

Node.js v17.3.0

Any idea how to resolve this?

1 Answer 1

1

Try adding the following to your package.json

  "browser": {
    "crypto": false
  },

If it doesn't work (when node version is 17), also add the following to your package.json

"dependencies": {
    "crypto-browserify": "^3.12.0",
    "crypto": "npm:crypto-browserify",
    "stream": "npm:stream-browserify"
  },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.