-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expo SDK 49 web (with metro) not working with react-hook-form #23322
Comments
just hit the same issue while upgrading from 48 to 49 |
I added the following line to my metro.config.ts to resolve this:
The whole thing:
|
@lenmazzone works perfectly! Related to #23180 (as including mjs (and cjs?) as default metro config should resolve the issue) |
Related issue for urql: urql-graphql/urql#3313 The same metro.config.js trick fixed this for urql 👍 I guess it would make sense to make this part of the default metro.config.js? |
This got me past the react-hook-forms error, but now I'm getting a new error about GestureHandler and the Drawer. This is only happening on web. I'm not quite sure what's going on tbh, possibly the above fix is not handling platform specific extensions? It's hard to say what's happening behind the scenes with all the transpiling and etc...
EDIT |
Any success with he hook problem? |
just ran into the same issue |
Just the same issue |
This is an unrelated issue, but all I had to do was |
@gorbypark any success with the DrawerLayoutAndroid issue? I'm getting almost an identical error:
Only difference is |
I believe that this is the problem: 6a750d0#r121599931 Adding |
Thanks! Adding the extensions worked for me as well. For those experiencing the |
Hi balgamat, have you found a solution for this yet, I'm having similar issue, and I'll need to access the web to write test. Let me know if you have a workaround or you've found the solution, thanks in advance... |
This fixes the issue. Thank you @lenmazzone |
I've got the same issue as @balgamat, and it's preventing me from using React Hook Form and Metro together on the web. This consequently prevents me from using Expo Router, which depends upon Metro! package.json:
metro.config.js:
Error:
|
I had similar issues, I was able to fix it by just adding webpack bundler, I think expo 49 is not really compatible with react-hook-form most especially on the web |
I have them working together fine on iOS & Android, but not on web. |
I have same issue with expo 49 managed metro.config.ts
on web I got this error Unable to resolve "react-hook-form" from "src\screens\authScreens\signUpScreen\SignUpScreen.tsx" on browser any solution suggested ?? |
I was able to get them working together on web by switching to webpack bundler instead of metro. There seems to be a fundamental incompatibility between metro for web and react-hook-form. |
We have added mjs support in Expo SDK 50, this should resolve the issue. |
Is there a fix for this for React Native Web? I can't upgrade to Expo SDK 50 right now since it caused other issues in the project. Were you able to fix this, @Hiba-Bazerbashi ? |
@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:
Is there a fix for this for React Native Web?
It's working for native, but it won't compile for web, giving the error:
"Web Bundling failed
Unable to resolve "react-hook-form" from "path\to\file\SignInScreen.tsx" "
I can't upgrade to Expo SDK 50 right now since it caused other issues in
the project.
Were you able to fix this, @Hiba-Bazerbashi
<https://github.com/Hiba-Bazerbashi> ?
—
Reply to this email directly, view it on GitHub
<#23322 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATXF3B6VFDXNFV4V2OJS4GLYSFGLHAVCNFSM6AAAAAA2AAJPU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRYGEZTSNRWGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@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. /* eslint-disable no-undef */
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
module.exports = (async () => {
const {
resolver: { sourceExts },
} = config;
return {
...config,
resolver: {
...config.resolver,
sourceExts: [...sourceExts, 'mjs'],
},
};
})(); |
@gorbypark That worked!
Chuck it up to a beginner mistake. Your config works perfectly, thanks mate ^^ |
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
The text was updated successfully, but these errors were encountered: