Skip to content
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

Metro error: Unable to resolve module stream/web #2806

Closed
sniffer72 opened this issue Feb 22, 2024 · 5 comments
Closed

Metro error: Unable to resolve module stream/web #2806

sniffer72 opened this issue Feb 22, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@sniffer72
Copy link

I am running into this issue as well and I have tried some of other pkg solution without luck.

npx create-expo-app coreApp --template tabs@50
Install firebase resources
% npm install firebase @react-native-firebase/app @react-native-firebase/auth

I am able to login to my mobile app with this tutorial on IOS but when I try using expo web I get that error below.
https://github.com/Cebraiil/firebase_auth_tutorial/blob/master/App.js

ERROR

Metro error: Unable to resolve module stream/web from /Users/justin/coreApp/node_modules/undici/lib/core/util.js: stream/web could not be found within the project or in these directories:
node_modules
369 | function ReadableStreamFrom (iterable) {
370 | if (!ReadableStream) {

371 | ReadableStream = require('stream/web').ReadableStream
| ^
372 | }
373 |
374 | if (ReadableStream.from) {

I have tried to install the stream npm package and that didn't solve it either.

Environment

% npm -v
10.4.0

% node -v
v18.19.0

package.json = does not work

{
"name": "coreapp",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "^14.0.0",
"@react-native-firebase/app": "^18.9.0",
"@react-native-firebase/auth": "^18.9.0",
"@react-navigation/native": "^6.0.2",
"expo": "~50.0.7",
"expo-font": "~11.10.3",
"expo-linking": "~6.2.2",
"expo-router": "~3.4.7",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"expo-system-ui": "~2.9.3",
"expo-web-browser": "~12.8.2",
"firebase": "^10.8.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.4",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
"react-native-web": "~0.19.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.45",
"jest": "^29.2.1",
"jest-expo": "~50.0.2",
"react-test-renderer": "18.2.0",
"typescript": "^5.1.3"
},
"pkg": {
"patches": {
"./node_modules/undici/lib/fetch/body.js": ["require('stream/web')", "require('stream').web"],
"./node_modules/undici/lib/core/util.js": ["require('stream/web')", "require('stream').web"],
"./node_modules/undici/lib/fetch/request.js": ["require('stream/web')", "require('stream').web"],
"./node_modules/undici/lib/fetch/index.js": ["require('stream/web')", "require('stream').web"]
}
},
"private": true
}

@sniffer72 sniffer72 added the bug Something isn't working label Feb 22, 2024
@mcollina
Copy link
Member

Undici is a library for Node.js. It's not a library for expo.

I'd recommend you to use global fetch instead (if it's available on Expo).

@mcollina mcollina closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
@sniffer72
Copy link
Author

I am not doing anything special in my application. I believe it has to do with the Undici lib calling something out of date or incorrectly.

@sniffer72
Copy link
Author

Here is some more information.

Firebase -> Undici -> stream/web (cannot be found or downloaded via npm or yarn)

Metro error: Unable to resolve module undici from /Users/justin/coreApp/node_modules/@firebase/auth/dist/node/index.js: undici could not be found within the project or in these directories:
node_modules
8 | require('@firebase/app');
9 | require('@firebase/component');

10 | require('undici');
| ^
11 | require('@firebase/logger');
12 |
13 |

@rbecs
Copy link

rbecs commented Mar 17, 2024

Has this been resolved yet? I am receiving the same error after connecting my app to Firebase.

@newyorksoul
Copy link

I am having the same problem with a basic expo@50 setup and firebase.js auth on web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants