react-native
react-native copied to clipboard
Unable to resolve module node:http
Description
Just forwarding a issue from our orgi to you...
fyi, I Don't have any involvement with react-native.
but it seems like you guys have an issue resolving node modules beginning with a node:
prefix / protocol
Version
n/a
Output of npx react-native info
n/a
Steps to reproduce
n/a
Description?
I'm working on a ReactNative app, and I was trying to make an HTTP request on an API. The implementation i have workes (I've been using it for a while now).
But with this new version 3.2.0
, when i import the file, I immediately get
Unable to resolve module node:http
in my the console cmd
,
and also this suggestion below.
If you are sure the module exists, try these steps:
- Clear watchman watches: watchman watch-del-all
- Delete node_modules and run yarn install
- Reset Metro's cache: yarn start --reset-cache
- Remove the cache: rm -rf /tmp/metro-*
Reproduction Steps to reproduce the behavior:
- yarn add node-fetch
- run the code above ( image )
Expected behavior
Screenshots
Snack, code example, screenshot, or link to a repository
No response
@jimmywarting just wondering, why are you using node-fetch? React-native bundles the fetch API out-of-the-box. No need to use node-fetch. (no need to import any lib, it's available at the global scope).
By the way, even if metro was able to import this library it would break when running on device. You see, node-fetch depends on the NodeJS environment which Android or iOS does not support. (You can't run NodeJS modules on the device - I mean modules that use the NodeJS api itself - which is your case)
i'm not using react-native, it was an other developer that had a problem with this. he had problem with node:
prefixes
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.