uuid: React Native require error

require('node-uuid') or import uuid form 'node-uuid' results in a Unable to resolve module crypto error.

If I switch out require('crypto') with require('crypto-js'), and specifically include the crypto-js library instead, it works fine. Are we able to look at swapping out crypto with crypto-js?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 6
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I hope Robert will get time to merge it, meanwhile I created little something as a temporary replacement: https://www.npmjs.com/package/react-native-uuid

@broofa you should add some contributor if you don’t have much time to merge some PRs or fix some issues

It can be temporarily resolved by using babel-plugin-module-resolver. Install babel-plugin-module-resolver

$ npm install --save-dev babel-plugin-module-resolver

And crypto-js

$ npm install --save crypto-js

Edit .babelrc

{
  "presets": [
    "react-native"
  ],
  "plugins": [
    ["module-resolver", {
      "alias": {
        "crypto": "crypto-js"
      }
    }]
  ]
}