-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing NPM library into React Native app breaks the app. #8
Comments
Versions and environment: |
Full package.json: { |
Temporary solution is to use rn-nodeify package(https://github.com/tradle/rn-nodeify). You can follow these steps to install:
In your app:
There is one current issue with RN 0.62.0 and higher. react-native-tcp and react-native-udp would cause the duplicate symbol issue on build: tradle/rn-nodeify#94 So, you can remove these packages or try the workaround described in issue. |
@eluzgin, let me know if this makes sense and helps. |
Step to reproduce:
Import "@fioprotocol/fiojs" library into a React Native application.
When running - the following error is thrown on app startup:
error: Error: Unable to resolve module
events
fromnode_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js
: events could not be found within the project.Stacktrace:
at ModuleResolver.resolveDependency (/Users/eugeneluzgin/Blockchain/kryptowallet/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:186:15)
at ResolutionRequest.resolveDependency (/Users/eugeneluzgin/Blockchain/kryptowallet/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (/Users/eugeneluzgin/Blockchain/kryptowallet/node_modules/metro/src/node-haste/DependencyGraph.js:287:16)
at Object.resolve (/Users/eugeneluzgin/Blockchain/kryptowallet/node_modules/metro/src/lib/transformHelpers.js:26
After performing recommended reset commands:
$ watchman watch-del-all
$ rm -rf node_modules
$ yarn install
$ react-native start
Then restarting application in iOS Simulator
Getting same error:
"error: Error: Unable to resolve module
events
fromnode_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js
: events could not be found within the project."The file listed above exists under node_modules.
I have done some research and found a similar issue reported here for AWS library:
aws-amplify/amplify-js#153
The common root cause are these dependencies:
fiojs has under it's dependencies create-hash and create-hmac:
"dependencies": {
"ajv": "^6.10.2",
"babel-runtime": "6.26.0",
"bigi": "^1.4.2",
"browserify-aes": "^1.2.0",
"bs58": "^4.0.1",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"ecurve": "^1.0.6",
"long": "^4.0.0",
"randombytes": "^2.1.0",
"text-encoding": "0.7.0"
},
Background: create-hmac and create-hash use a hash-base module. That does a
"var Transform = require('stream').Transform". That was defined in node.js core (NOT a standard JS function, see https://nodejs.org/api/stream.html#stream_new_stream_transform_options)
The text was updated successfully, but these errors were encountered: