teovillanueva / react-native-web-maps

Cross platform maps for react & react-native 🗺
https://teovillanueva.github.io/react-native-web-maps/
MIT License
54 stars 14 forks source link

Expo Web Build Error: Crypto? #41

Closed alexcittadini closed 3 months ago

alexcittadini commented 3 months ago

I have started a new minimalist build with expo. I've added react-native-web-maps and react-native-maps and the web simulator works fine, the ios simulator works fine, but when I runnpx expo build:webI get the following error.

Failed to compile.

Module not found: Error: Can't resolve 'crypto' in '/Users/Alex/apps/liveWindApp/node_modules/expo-modules-core/build/uuid'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
    - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "crypto": false }

If I remove the react-native-web-maps import from my code the build works fine. I don't use crypto at all and have not added it to my project.

Package.json below

{
  "name": "livewindapp",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/metro-runtime": "~3.1.3",
    "@teovilla/react-native-web-maps": "^0.9.4",
    "expo": "~50.0.14",
    "expo-status-bar": "~1.11.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.73.6",
    "react-native-maps": "1.10.0",
    "react-native-web": "~0.19.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}
alexcittadini commented 3 months ago

I was able to remove the error by updating the create-expo-app package and starting a new project following all the same steps so the issue was probably in a discrepancy in the project setup