问题
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
, ornpm 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