8000 GitHub · Where software is built
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Importing NPM library into React Native app breaks the app. #8
Open
@eluzgin

Description

@eluzgin

Step to reproduce:

  1. Import "@fioprotocol/fiojs" library into a React Native application.

  2. When running - the following error is thrown on app startup:
    error: Error: Unable to resolve module events from node_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

  3. 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 from node_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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0