From c81ef709d1e0b43a6123685f46501dcc3db1e2aa Mon Sep 17 00:00:00 2001 From: Peter van Hardenberg Date: Mon, 19 Mar 2018 10:58:24 -0700 Subject: [PATCH] react-native doesn't want crypto set to an empty module (#14) React-Native is sort of like a browser, sort of a native environment. On react-native we don't have the browser's crypto implementation, so we need to require react-native-crypto. We can rewrite the module requirement to do that using the extraNodeModules feature in rn-cli.config.js, but the metro packager assumes that if there's a "browser" field in package.json that it's relevant to react-native libraries unless there's also a "react-native" field. Hurray. Anyway, this silly little patch tells metro not to replace crypto with an empty module but actually to use whatever you currently have crypto set to (which is not solved here, so you'll still have to do that.) --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 5f3585b..8769fce 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "browser": { "crypto": false }, + "react-native": { + "crypto": "crypto" + }, "scripts": { "browser": "browserify test.js | browser-run", "browser-manual": "browserify test.js | browser-run -p 1234",