问题开始在模拟器一个反应-本机应用程序

问题描述 投票:0回答:1

这是我的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"
  }
}

而我得到以下的故障日志:

加载依赖关系图,完成。错误:捆绑失败:错误:在Function.Module._resolveFilename找不到模块 'NativeModules'(内部/模块/ CJS / loader.js:581:15)在Function.Module._load(内部/模块/ CJS / loader.js :507:25)在Module.require(内部/模块/ CJS / loader.js:637:17)在要求(内部/模块/ CJS / helpers.js:20:18)在Object.get NativeModules [如NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native/Libraries/react-native/react-native-implementation.js:313:12)在Object.get [按NativeModules](/用户/ vb05mj /开发商/个人/小城镇/当地人/ node_modules /反应,本机矢量图标/距离/ lib目录/反应-native.js:1:344)的对象。 (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/ensure-native-module-available.js:1:238)在Module._compile(内部/modules/cjs/loader.js:689:30)

reactjs react-native
1个回答
1
投票

运行rm -rf node_modules && npm install重新安装的依赖关系。

确保react-native-vector-icons链接正确。通常你应该有android/app/build.gradle内这一行:

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

这里更多的信息:https://github.com/oblador/react-native-vector-icons#android

杀死NPM服务器(Ctrl + C或只是运行kill -15 [pid]),并使用npm start -- --reset-cache重新启动

最后,不要忘了重建您的应用程序:./android/gradlew clean && react-native run-android


推荐问答