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

Error: Unable to resolve module 'stream' #33981

Closed
t104360088 opened this issue Jun 9, 2022 · 7 comments
Closed

Error: Unable to resolve module 'stream' #33981

t104360088 opened this issue Jun 9, 2022 · 7 comments
Labels
Resolution: Answered When the issue is resolved with a simple answer

Comments

@t104360088
Copy link

Description

The project was working fine a while ago, but suddenly it can't be executed, can anyone help me?
I have tried any clear command and action.

error: Error: Unable to resolve module stream from D:.........\node_modules\readable-stream\readable.js: stream could not be found within the project or in these directories:
node_modules\readable-stream\node_modules
node_modules

If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro-*

1 | exports = module.exports = require('./lib/_stream_readable.js');
| ^
2 | exports.Stream = require('stream');
3 | exports.Readable = exports;
4 | exports.Writable = require('./lib/_stream_writable.js');

Version

0.64

Output of npx react-native info

System:
OS: Windows 10 10.0.18363
CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
Memory: 16.13 GB / 31.96 GB
Binaries:
Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.10.0 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-212.5712.43.2112.8512546
Visual Studio: Not Found
Languages:
Java: 11.0.15
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.1 => 0.64.1
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Run the code

Snack, code example, screenshot, or link to a repository

image

@retyui
Copy link
Contributor

retyui commented Jun 16, 2022

@t104360088 stream it is Node.js code module, and not available in react native environment.

you should avoid importing "readable-stream"

Can you show output of:

yarn why readable-stream

@shafqatbari
Copy link

Macs-MacBook-Pro:testsock mac$ yarn why readable-stream
yarn why v1.22.17
[1/4] 🤔 Why do we have the module "readable-stream"...?
[2/4] 🚚 Initialising dependency graph...
[3/4] 🔍 Finding dependency...
[4/4] 🚡 Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "readable-stream"
info Reasons this module exists

  • Specified in "dependencies"
  • Hoisted from "stream-browserify#readable-stream"
    info Disk size without dependencies: "164KB"
    info Disk size with unique dependencies: "260KB"
    info Disk size with transitive dependencies: "260KB"
    info Number of shared dependencies: 4
    => Found "bl#[email protected]"
    info This module exists because "react-native#@react-native-community#cli-platform-ios#ora#bl" depends on it.
    info Disk size without dependencies: "192KB"
    info Disk size with unique dependencies: "260KB"
    info Disk size with transitive dependencies: "260KB"
    info Number of shared dependencies: 3
    => Found "through2#[email protected]"
    info This module exists because "react-native#metro-source-map#metro-symbolicate#through2" depends on it.
    info Disk size without dependencies: "168KB"
    info Disk size with unique dependencies: "348KB"
    info Disk size with transitive dependencies: "348KB"
    info Number of shared dependencies: 7
    ✨ Done in 0.73s.

@shafqatbari
Copy link

@retyui

@retyui
Copy link
Contributor

retyui commented Jun 24, 2022

@shafqatbari Did you use stream-browserify, bl or through2 in your code ?
if yes them remove them or replace with compatible version for RN

@cortinico
Copy link
Contributor

stream it is Node.js code module, and not available in react native environment.

Closing as this has been answered by @retyui (thanks for doing it 🙏 )
You should not be using Node.js core module in your React native application as they're not available.

@cortinico cortinico added Resolution: Answered When the issue is resolved with a simple answer and removed Needs: Triage 🔍 📦Bundler labels Jun 24, 2022
@PS8924
Copy link

PS8924 commented Sep 19, 2022

Than which module should we use to read readablestream in react native?

@shamilovtim
Copy link
Contributor

shamilovtim commented Feb 13, 2023

RN needs ReadableStream support. Yes, it's not a node environment. However this API is used by the broader web, and supporting it is supporting a basic commonly available web technology that's missing in RN. It looks bad on RN's part that it doesn't have support for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Answered When the issue is resolved with a simple answer
Projects
None yet
Development

No branches or pull requests

7 participants