Twilio React Native - Unable to resolve module crypto

前端 未结 4 535
孤独总比滥情好
孤独总比滥情好 2020-12-31 12:24

I\'m working on implementing the twilio package into my react-native project and when I require it in my file the project wont load and I\'m seeing the followin

4条回答
  •  無奈伤痛
    2020-12-31 13:13

    You can use the rn-nodeify module to get crypto on react-native.

    Add rn-nodeify to your devDependencies in package.json:

    "devDependencies": {
      "rn-nodeify": "^6.0.1"
    }
    

    Add the following to the scripts section of the same file:

    "scripts": {
      …
      "postinstall": "node_modules/.bin/rn-nodeify --install crypto --hack"
    }
    

    Be aware that rn-nodeify will modify your package.json.

    More information available here: https://www.npmjs.com/package/rn-nodeify

提交回复
热议问题