react-native-maps: Getting error 'requireNativeComponent' is not exported from 'react-native-web/dist/index'.
Bug report
Getting error in loading maps on expo
<homeDirectory>/reactNativeLearning/tracks/node_modules/react-native-maps/lib/components/MapView.js Attempted import error: ‘requireNativeComponent’ is not exported from ‘react-native-web/dist/index’.
Environment info
react-native info output:
info Fetching system and libraries information...
System:
OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
Memory: 225.72 MB / 7.69 GB
Shell: 5.0.16 - /bin/bash
Binaries:
Node: 10.19.0 - /usr/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npm: 6.14.4 - /usr/bin/npm
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: Not Found
Python: 2.7.18 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4
npmGlobalPackages:
*react-native*: Not Found
Library version: x.x.x
Steps to reproduce
- Added the package using npm install react-native-maps
- Added a js file and imported the MapView using
import MapView from "react-native-maps"; - ran the server using npm start - expo server started
- Error in the console: /home/sunil/myWork/reactNativeLearning/tracks/node_modules/react-native-maps/lib/components/MapView.js Attempted import error: ‘requireNativeComponent’ is not exported from ‘react-native-web/dist/index’.
/home/sunil/myWork/reactNativeLearning/tracks/node_modules/react-native-maps/lib/components/MapView.js Attempted import error: ‘requireNativeComponent’ is not exported from ‘react-native-web/dist/index’.
/home/sunil/myWork/reactNativeLearning/tracks/node_modules/react-native-maps/lib/components/decorateMapComponent.js Attempted import error: ‘requireNativeComponent’ is not exported from ‘react-native-web/dist/index’.
/home/sunil/myWork/reactNativeLearning/tracks/node_modules/react-native-maps/lib/components/decorateMapComponent.js Attempted import error: ‘requireNativeComponent’ is not exported from ‘react-native-web/dist/index’. Describe what you expected to happen:
- Map should be displayed
- …
Reproducible sample code
import React from “react”; import { View, Text, StyleSheet } from “react-native”; import MapView from “react-native-maps”;
const Map = () => { return ( <View> <MapView style={styles.map} initialRegion={{ latitude: 37.78825, longitude: -122.4324, latitudeDelta: 0.0922, longitudeDelta: 0.0421, }} /> </View> ); };
const styles = StyleSheet.create({ map: { height: 300, }, });
export default Map;

About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23
Is anyone looking at this issue of resolving?
Same issue here. Just adding import MapView from react-native-maps crashes things. Even if I don’t use it
I couldn’t run it under the web either using
or in any other way. But, after all, everything worked out.
In other words, for Android and iOs, react-native-maps will be used as before, and for web react-native-web-maps.
upd. But, unfortunately, react-native-web-maps can’t do almost anything. Minimal functionality - map and markers.
use: expo install react-native-maps
any update on this one?
When I do expo install react-native-maps I get
what should I do with that? what exactly is it conflicting with ?
So i am trying to make an app that runs as a mobile app, but also i want to reuse as much of the code as possible for a web app. I was looking at doing PWA. But i thought maybe i could react-native map also in web? i am getting a similar error.
Is this even possible to do? or should i just try and do a PWA.
Thank you, this did the trick and I now understand why I should install via expo. Solved for my part!