typeorm: Unable to resolve module `crypto` from `node_modules/typeorm/browser/util/StringUtils.js`

Issue type:

[ ] question [x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [ ] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [x] react-native [ ] expo

TypeORM version:

[ ] latest [ ] @next [x] 0.2.22 (this is the latest at this moment)

When using with React Native I’m getting “Unable to resolve module crypto” error when trying to use TypeORM. The issue appears in the 0.2.22 only. This is due to the following recent change: https://github.com/typeorm/typeorm/commit/edc8e6dfd2c250656ab5b143297c60f57787ce77#diff-3fbb9e2b917220327e7c2fe6522c9b6d

Steps to reproduce or a small repository showing the problem:

react-native init TypeormHash cd TypeormHash Add "import {Entity} from 'typeorm/browser';" at the top of App.js react-native run-android

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 17 (11 by maintainers)

Most upvoted comments

I guess this is open for discussions as I’m not sure this is the right approach. My own fix is to use sha.js instead of “crypto” which is not available in RN: https://github.com/nochkin/typeorm/commit/ba160304f89e8a533b075d4af9961066a09bd05a I can make a PR if this is acceptable.

Can we have a release please? The latest version is broken on React Native.

Guys, I feel like you’re kind of ganging up on @nochkin for no good reason.

  1. The problem has been fixed. Another similar problem will be more effectively dealt with by opening a new Github issue instead of commenting on an already forgotten one.
  2. There’s nothing wrong with the solution used here. SHA256 is not secure anyway, there’s no need to overthink it.

I think this issue would best be closed.