Skip to content

Import the polkadot-api in React-Native, The error summary #481

@0xthreebody

Description

@0xthreebody

polkadot Api version :

    "@polkadot/api": "^0.33.17",
    "@polkadot/rpc-provider": "^0.33.17"

This React-Native project create way is :
react-native init Project

cd Project
react-native run-android

packages:

"dependencies": {
    "axios": "0.18.0",
    "ethers": "3.0.27",
    "identicon.js": "2.3.2",
    "mobx": "^4.3.1",
    "mobx-react": "5.2.5",
    "moment": "2.22.2",
    "react": "16.4.2",
    "react-native": "0.56.0",
    "react-native-camera": "1.2.0",
    "react-native-modal": "6.5.0",
    "react-native-permissions": "1.1.1",
    "react-native-qrcode-svg": "5.1.0",
    "react-native-sensitive-info": "5.2.4",
    "react-native-snackbar": "0.5.0",
    "react-native-svg": "6.5.2",
    "react-native-vector-icons": "5.0.0",
    "react-navigation": "2.12.1",
    "@polkadot/api": "^0.33.17",
    "@polkadot/rpc-provider": "^0.33.17"
  },
  "devDependencies": {
    "@babel/core": "7.0.0-beta.47",
    "@babel/plugin-proposal-decorators": "7.0.0-beta.47",
    "@babel/plugin-transform-runtime": "7.0.0-beta.47",
    "@babel/runtime": "7.0.0-beta.47",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "23.4.2",
    "babel-plugin-module-resolver": "3.1.1",
    "babel-preset-react-native": "5.0.2",
    "enzyme": "3.5.0",
    "enzyme-adapter-react-16": "1.3.0",
    "eslint-config-rallycoding": "3.2.0",
    "jest": "23.5.0",
    "jsdom": "12.0.0",
    "react-native-mock-render": "0.1.1",
    "react-test-renderer": "16.4.2",
    "rimraf": "^2.6.2"
  },

When I import the @polkadot/api to React Native project. get the error:

error: bundling failed: Error: Unable to resolve module `core-js/modules/es6.regexp.to-string` from `/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/@polkadot/util/logger.js`: Module `core-js/modules/es6.regexp.to-string` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.

_ _20181217193346

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

Body:
{"originModulePath":"/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/@polkadot/util/logger.js","targetModuleName":"core-js/modules/es6.regexp.to-string","message":"Unable to resolve module `core-js/modules/es6.regexp.to-string` from `/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/@polkadot/util/logger.js`: Module `core-js/modules/es6.regexp.to-string` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n  1. Clear watchman watches: `watchman watch-del-all`.\n  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.","errors":[{"description":"Unable to resolve module `core-js/modules/es6.regexp.to-string` from `/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/@polkadot/util/logger.js`: Module `core-js/modules/es6.regexp.to-string` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n  1. Clear watchman watches: `watchman watch-del-all`.\n  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`."}],"name":"Error","stack":"Error: Unable to resolve module `core-js/modules/es6.regexp.to-string` from `/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/@polkadot/util/logger.js`: Module `core-js/modules/es6.regexp.to-string` does not exist in the Haste module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n  1. Clear watchman watches: `watchman watch-del-all`.\n  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.\n    at ModuleResolver.resolveDependency (/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:167:1306)\n    at ResolutionRequest.resolveDependency (/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:80:16)\n    at DependencyGraph.resolveDependency (/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/node-haste/DependencyGraph.js:237:485)\n    at Object.resolve (/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/lib/transformHelpers.js:116:25)\n    at dependencies.map.result (/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:298:29)\n    at Array.map (<anonymous>)\n    at resolveDependencies (/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:294:16)\n    at /media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:159:33\n    at Generator.next (<anonymous>)\n    at step (/media/threebody/DATA/Desktop/github/ethereum-wallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:239:307)"}
processBundleResult
    BundleDownloader.java:285
access$200
    BundleDownloader.java:37
onResponse
    BundleDownloader.java:163
execute
    RealCall.java:153
run
    NamedRunnable.java:32
runWorker
    ThreadPoolExecutor.java:1162
run
    ThreadPoolExecutor.java:636
run
    Thread.java:764

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTracks issues causing errors or unintended behavior, critical to fix for reliability.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions