0
votes

This is my package.json

{
  "name": "Locals",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@babel/runtime": "^7.3.1",
    "react": "16.6.3",
    "react-native": "0.58.3",
    "react-native-elements": "^1.0.0",
    "react-native-vector-icons": "^6.2.0"
  },
  "devDependencies": {
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "24.0.0",
    "jest": "24.0.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

And I get following logs of failure:

Loading dependency graph, done. error: bundling failed: Error: Cannot find module 'NativeModules' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.get NativeModules [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native/Libraries/react-native/react-native-implementation.js:313:12) at Object.get [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/react-native.js:1:344) at Object. (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/ensure-native-module-available.js:1:238) at Module._compile (internal/modules/cjs/loader.js:689:30)

1
You have to save the version in package.json. Did you run npm install react-native-vector-icons --save , and then link it as a native dependency with react-native link react-native-vector-iconsstever
Yes, did not help.Prabhat Ranjan
Well, the problem seems to be react-native-vector-icons. My next step would be to react-native unlink react-native-vector-icons && npm remove react-native-vector-icons and try reinstalling (making sure I used npm install react-native-vector-icons --save and react-native link react-native-vector-iconsstever

1 Answers

1
votes

Run rm -rf node_modules && npm install to reinstall the dependencies.

Make sure that react-native-vector-icons is properly linked. Usually you should have this line within android/app/build.gradle:

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

More info here: https://github.com/oblador/react-native-vector-icons#android

Kill the npm server (ctrl+c or just run kill -15 [pid]) and restart it using npm start -- --reset-cache

Finally, don't forget to rebuild your app: ./android/gradlew clean && react-native run-android