Optional `require` doesn't work as expected
See original GitHub issueDo you want to request a feature or report a bug?
Report a bug
Current behavior
I wanted to implement an optional require
that was discussed here. It’s said that this functionality has been added in metro 59.0, PR. RN 0.64.0 uses @react-native-community/cli version 5.0.1-alpha.0(here) and that uses metro version 0.64.0(here) so that change should be included there.
Ok, there’s a stack trace but still, I don’t think this functionality works as expected.
Reproducing the issue
I just installed an RN app with this commend: npx react-native init appName --version 0.64.0
and added some js code to test the thing.
Reproducing repository
Here is the repository.
Clone the repo I posted, install the packages(yarn && cd ios && pod install
), run the app, and press the button with the label FAIL
.
Expected behavior
Running the app from the repro I linked, I still get the Redbox. I want to be able to handle a lack of files in require
on my own providing a specific error message with instructions on what can be done(or do whatever I want with this basically). Instead, I get the Redbox with something like this:
ERROR Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run `yarn` or `npm install`.
Am I missing something or the optional require
is broken?
Configuration
- Metro:
0.64.0
(comes with RN0.64.0
) - Node:
v15.11.0
- yarn:
1.22.10
- OS:
MacOs BigSur 11.2.3 (20D91)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:6
Top GitHub Comments
I’m also experiencing the same, I’m using react native 0.64.1.
EDIT. I was able to fix this issue by changing
inlineRequires: true
tofalse
in themetro.config.js
file.Running into the same issue. Did you ever solve this?