tradle / react-native-crypto

partial implementation of node's `crypto` for react-native
MIT License
372 stars 85 forks source link

error: Error: Unable to resolve module process #63

Open forge-phap-dinh opened 3 years ago

forge-phap-dinh commented 3 years ago

I am using react native 0.66 and after I import the shim file and run the app I get this error

error: Error: Unable to resolve module process ...

process could not be found within the project or in these directories: node_modules

If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro-* 1 | if (typeof dirname === 'undefined') global.dirname = '/' 2 | if (typeof filename === 'undefined') global.filename = ''

    3 | if (typeof process === 'undefined') { | ^ 4 | global.process = require('process') 5 | } else { 6 | const bProcess = require('process')

walkstreet commented 2 years ago

I got the same problem.

walkstreet commented 2 years ago
yarn add react-native-crypto
# install peer deps
yarn add react-native-randombytes
npx react-native link react-native-randombytes
# on RN >= 0.60, instead do:
cd iOS && pod install
# install latest rn-nodeify
yarn add rn-nodeify
# install node core shims and recursively hack package.json files
# in ./node_modules to add/update the "browser"/"react-native" field with relevant mappings
npx rn-nodeify --install buffer,crypto,stream,util,process,vm --hack

Maybe I've got the answer. You can follow these steps to work it out.