0

When I attempt and import crypto, I keep getting this error message on React.

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

This is the current code:

const { createHash } = require('crypto');

function calculateIdHash(input) {
    return createHash('sha256').update(input).digest('hex');
}

I even tried import { createHash } from 'crypto', and the same error message popped up. Any help would be great. Thanks.

incog
  • 101
  • 3
  • Did you check the different solutions here https://stackoverflow.com/questions/54162297/module-not-found-error-cant-resolve-crypto – Varadharajan Raghavendran Feb 18 '22 at 17:13
  • what nodejs version are you using ? in docs said you can check if your nodejs support crypto by using a try-catch syntax. Take a look at [this](https://nodejs.org/api/crypto.html#crypto) link – Anji Feb 18 '22 at 17:14

0 Answers0