【发布时间】:2018-09-10 08:15:18
【问题描述】:
我想从here 实现 react-native-maps。
但是当我在App.js 上使用代码import MapView from 'react-native-maps'; 导入上面的 MapView 时,我得到了这个错误:
需要未知模块“未定义”。如果您确定该模块存在,请尝试重新启动 Metro Bundler。您可能还想运行
yarn或npm install(取决于您的环境)。
我的package.json 是
{
"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"
}
}
【问题讨论】:
-
你能告诉我们你的 package.json 吗?您是否尝试重新调整 react-native 打包程序?您是否正确链接了模块? (查看如何github.com/react-community/react-native-maps/blob/master/docs/…)
-
是的,我做到了,但错误再次存在,我的 package.json 已根据我的问题更新。
标签: ios reactjs react-native react-native-maps