node-fetch cause error with latest version react native
See original GitHub issueBy trying to load this plugin relam-js on android, I got error below:
E/ReactNativeJNI( 4323): Got JS Exception: Requiring unknown module "node-fetch". (index.android.bundle:2)
E/ReactNativeJNI( 4323): Got JS Stack: i@index.android.bundle:2:688
E/ReactNativeJNI( 4323): n@index.android.bundle:2:331
E/ReactNativeJNI( 4323): t@index.android.bundle:2:245
E/ReactNativeJNI( 4323): e@index.android.bundle:2:94
E/ReactNativeJNI( 4323): index.android.bundle:315:1873
E/ReactNativeJNI( 4323): index.android.bundle:315:1857
E/ReactNativeJNI( 4323): n@index.android.bundle:2:470
E/ReactNativeJNI( 4323): t@index.android.bundle:2:245
E/ReactNativeJNI( 4323): e@index.android.bundle:2:94
E/ReactNativeJNI( 4323): exports@index.android.bundle:322:1321
E/ReactNativeJNI( 4323): index.android.bundle:303:1262
E/ReactNativeJNI( 4323): n@index.android.bundle:2:470
E/ReactNativeJNI( 4323): t@index.android.bundle:2:245
E/ReactNativeJNI( 4323): e@index.android.bundle:2:94
E/ReactNativeJNI( 4323): index.android.bundle:302:43
E/ReactNativeJNI( 4323): n@index.android.bundle:2:470
E/ReactNativeJNI( 4323): t@index.android.bundle:2:245
E/ReactNativeJNI( 4323): e@index.android.bundle:2:94
E/ReactNativeJNI( 4323): index.android.bundle:298:117
E/ReactNativeJNI( 4323): n@index.android.bundle:2:470
E/ReactNativeJNI( 4323): t@index.android.bundle:2:245
E/ReactNativeJNI( 4323): e@index.android.bundle:2:94
E/ReactNativeJNI( 4323): index.android.bundle:297:127
E/ReactNativeJNI( 4323): n@index.android.bundle:2:470
E/ReactNativeJNI( 4323): t@index.android.bundle:2:245
E/ReactNativeJNI( 4323): e@index.android.bundle:2:94
E/ReactNativeJNI( 4323): index.android.bundle:12:38
E/ReactNativeJNI( 4323): n@index.android.bundle:2:470
E/ReactNativeJNI( 4323): t@index.android.bundle:2:175
E/ReactNativeJNI( 4323): e@index.android.bundle:2:94
E/ReactNativeJNI( 4323): global code@index.android.bundle:765:9
E/AndroidRuntime( 4323): FATAL EXCEPTION: mqt_js
E/AndroidRuntime( 4323): Process: eu.app.test, PID: 4323
E/AndroidRuntime( 4323): java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Requiring unknown module "node-fetch". (index.android.bundle:2)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:24)
E/AndroidRuntime( 4323): at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:172)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:496)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.CatalystInstanceImpl.access$900(CatalystInstanceImpl.java:41)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:512)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:33)
E/AndroidRuntime( 4323): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
E/AndroidRuntime( 4323): at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime( 4323): Caused by: com.facebook.react.devsupport.JSException: Requiring unknown module "node-fetch". (index.android.bundle:2)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
E/AndroidRuntime( 4323): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime( 4323): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 4323): at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
E/AndroidRuntime( 4323): ... 3 more
E/AndroidRuntime( 4323): Caused by: com.facebook.jni.CppException: Requiring unknown module "node-fetch". (index.android.bundle:2)
E/AndroidRuntime( 4323): ... 7 more
This line is some wrong, really bad idea. https://github.com/realm/realm-js/blob/4055c9e047b93053eb35402dfc56f2e57e260b92/lib/user-methods.js#L40
Just should be require(‘node-fetch’) for processing and making bundle on platform react native.
Goals
Expected Results
Actual Results
Steps to Reproduce
Code Sample
Version of Realm and Tooling
- Realm JS SDK Version: 1.13.0
- Node or React Native: React Native
- Client OS & Version: Windows 10
- Which debugger for React Native: ?/None
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
node-fetch Error [ERR_REQUIRE_ESM]: require() of ES ...
The node-fetch error "[ERR_REQUIRE_ESM]: require() of ES Module not supported" occurs because the node-fetch package has been converted to be an ESM-only ...
Read more >Developers - node-fetch cause error with latest version react native -
By trying to load this plugin relam-js on android, I got error below: E/ReactNativeJNI( 4323): Got JS Exception: Requiring unknown module "node-fetch".
Read more >node-fetch - npm
A light-weight module that brings Fetch API to Node.js. Build status Coverage status Current version Install size Mentioned in Awesome Node.js ...
Read more >expo Unable to resolve "fetch" - node.js - Stack Overflow
According to Expo doc you don't need to import anything. Just use fetch in the code. import React from 'react'; import { FlatList, ......
Read more >Troubleshooting - React Native
You will also need to update your applications to load the JavaScript bundle from the new port. If running on device from Xcode,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

We are working on upgrading to RN 0.50. I believe it is related to that version, and I hope that we will be able to reproduce the error. See #1483.
I get the same error, but the workaround didn’t work for me.
I can’t really provide an example project since it’s private code, but this has caused our entire production to shut down.
Edit: As below, happening on a Mac (Windows too though). Same versions too:
Rn: 0.50.1 React : 16.0.0 Realm : 1.13.0