Skip to content

import 'ipfs-lite' caused BUNDLE error with metro resolver in React Native #269

Open
@emclab

Description

Describe the bug

      import { Peer, BlockStore } from '@textile/ipfs-lite/core';
      import { setupLibP2PHost, MemoryDatastore } from '@textile/ipfs-lite/setup/';

The import statements above causes path related error:

  [Tue May 19 2020 16:23:51.370]  BUNDLE  ./index.js
  error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received     type boolean (false)
   at validateString (internal/validators.js:117:11)
   at Object.dirname (path.js:583:5)
   at resolveFileOrDir (C:\D\code\js\ipat_js\node_modules\metro-resolver\src\resolve.js:256:24)
   at Object.resolve (C:\D\code\js\ipat_js\node_modules\metro-resolver\src\resolve.js:151:20)
   at ModuleResolver.resolveDependency (C:\D\code\js\ipat_js\node_modules\metro\src\node-   haste\DependencyGraph\ModuleResolution.js:143:31)
   at ResolutionRequest.resolveDependency (C:\D\code\js\ipat_js\node_modules\metro\src\node-   haste\DependencyGraph\ResolutionRequest.js:52:18)
   at DependencyGraph.resolveDependency (C:\D\code\js\ipat_js\node_modules\metro\src\node-   haste\DependencyGraph.js:287:16)
   at Object.resolve (C:\D\code\js\ipat_js\node_modules\metro\src\lib\transformHelpers.js:267:42)
   at C:\D\code\js\ipat_js\node_modules\metro\src\DeltaBundler\traverseDependencies.js:434:31
   at Array.map (<anonymous>)

To Reproduce
Steps to reproduce the behavior:

  1. Create a React Native app
  2. install rn-nodeify and all shims
  3. Install ipfs-lite
  4. Add the import in App.js and launch the app

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Win10
  • React Native 0.62.2
  • Nodejs : 12.16
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6] Android 8.1 simulator
  • OS: [e.g. iOS8.1] Android 8.1
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

package.json:

{
"name": "ipat_js",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"postinstall": "./node_modules/.bin/rn-nodeify --install fs,path,process,buffer,crypto,stream,vm --hack"
},
"dependencies": {
"@textile/ipfs-lite": "^0.1.6",
"@tradle/react-native-http": "^2.0.0",
"assert": "^1.1.1",
"browserify-zlib": "^0.1.4",
"buffer": "^4.9.1",
"console-browserify": "^1.1.0",
"constants-browserify": "^1.0.0",
"dns.js": "^1.0.1",
"domain-browser": "^1.1.1",
"events": "^1.0.0",
"https-browserify": "0.0.1",
"path-browserify": "0.0.0",
"process": "^0.11.0",
"punycode": "^1.2.4",
"querystring-es3": "^0.2.1",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-crypto": "^2.1.0",
"react-native-level-fs": "^3.0.0",
"react-native-os": "^1.0.1",
"react-native-randombytes": "^3.0.0",
"react-native-tcp": "^3.2.1",
"react-native-udp": "^2.1.0",
"readable-stream": "^1.0.33",
"stream-browserify": "^1.0.0",
"string_decoder": "^0.10.31",
"timers-browserify": "^1.0.1",
"tty-browserify": "0.0.0",
"url": "^0.10.3",
"util": "^0.10.4",
"vm-browserify": "0.0.4"
},
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/runtime": "^7.9.6",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.5.1",
"eslint": "^6.8.0",
"jest": "^25.5.3",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.11.0",
"rn-nodeify": "^10.2.0"
},
"jest": {
"preset": "react-native"
},
"react-native": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "@tradle/react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify",
"tls": false
},
"browser": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "@tradle/react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify",
"tls": false
},
"metro": {
"resolver": {

  }
}

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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