Requiring unknown module “undefined” on react-native-maps

不羁的心 提交于 2019-12-12 13:16:30

问题


I want to implement react-native-maps from here. But when I import MapView above on App.js with the code import MapView from 'react-native-maps'; I get this error:

Requiring unknown module "undefined".If you are sure the module is there, try restarting Metro Bundler. You may also want to run yarn, or npm install (depending on your environement).

My package.json is

{
  "name": "MyNewProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "npm": "^5.8.0",
    "react": "16.3.0-rc.0",
    "react-native": "0.54.4",
    "react-native-image-picker": "^0.26.7",
    "react-native-maps": "^0.20.1"
  },
  "devDependencies": {
    "babel-jest": "22.4.3",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.3",
    "react-test-renderer": "16.3.0-rc.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

回答1:


Try changing this from your package.json "react-native-maps": "^0.20.1" into this "react-native-maps": "https://github.com/react-community/react-native-maps.git"` to ensure that you will use the master branch as suggested here https://github.com/react-community/react-native-maps/issues/2051#issuecomment-371530715



来源:https://stackoverflow.com/questions/49588806/requiring-unknown-module-undefined-on-react-native-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!