expo: Expo SDK 49 web (with metro) not working with react-hook-form
Minimal reproducible example
Had before. I seemly deleted it after some point
Summary
Template project from “https://docs.expo.dev/routing/installation/” and upgrading app according to “https://blog.expo.dev/expo-sdk-49-c6d398cdf740”.
npm run web > blank page with following error in terminal:
Unable to resolve "react-hook-form" from "app\(tabs)\index.tsx",
and in chrome console:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)Refused to execute script from 'http://localhost:8081/index.ts.bundle?platform=web&dev=true&hot=false&lazy=true' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
Environment
expo-env-info 1.0.5 environment info: System: OS: Windows 10 10.0.19045 Binaries: Node: 18.14.2 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Local\pnpm\yarn.CMD npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD npmPackages: expo: ^49.0.0 => 49.0.0 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.72.1 => 0.72.1 react-native-web: ~0.19.6 => 0.19.6 Expo Workflow: managed
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 12
- Comments: 25 (6 by maintainers)
I added the following line to my metro.config.ts to resolve this:
config.resolver.sourceExts = [...config.resolver.sourceExts, "mjs", "cjs"];The whole thing:
We have added mjs support in Expo SDK 50, this should resolve the issue.
@Hiba-Bazerbashi @hadiDanial Can you post your metro.config.js? I have a project on SDK49 and using expo web (expo-router/metro based) and the solution provided at the top of this issue works for me. Here is my metro.config.js, there’s a number of ways to accomplish it, but you just have to make sure you are adding the mjs extension so metro knows to bundle them. You will also have to make sure to restart metro and clear the cache after making changes.
@hadiDanial .there’s no way to get it to work on web with metro, it’s kind of wasting time , but if you want to switch to webpack it works as answers above, but i didnt do that it’s not advisable to switch to webpack ,so either to use another 3d party library or to upgrade to expo 50 , the latter was my choice and expo 50 working fine with no issues right now , try to get it from npm website not from expo docs
On Tue, 6 Feb 2024, 12:37 am hadiDanial, @.***> wrote:
I have them working together fine on iOS & Android, but not on web.
I believe that this is the problem: https://github.com/expo/expo/commit/6a750d0620da88294f9f1c7bada2cb5b6d7df3ff#r121599931
Adding
mjsandcjstowatcher.additionalExtsseems to resolve the issueThis is an unrelated issue, but all I had to do was
npx expo install react-native-gesture-handler. @andreiascendia @nasir733Just the same issue