cheeriojs / cheerio

The fast, flexible, and elegant library for parsing and manipulating HTML and XML.
https://cheerio.js.org
MIT License
28.42k stars 1.64k forks source link

attempted to import the Node standard library module "node:stream" in React Native project #4005

Open FloppiTuna opened 1 month ago

FloppiTuna commented 1 month ago

Previously, I was able to use Cheerio in one of my React Native applications. However after the recent release of v1.0.0 I receive an error upon launch due to it trying to import a NodeJS exclusive library:

The package at "node_modules/cheerio/dist/commonjs/index.js" attempted to import the Node standard library module "node:stream".
It failed because the native React runtime does not include the Node standard library.

expo-env-info output:

  expo-env-info 1.2.0 environment info:
    System:
      OS: macOS 15.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.20.4 - ~/.nvm/versions/node/v18.20.4/bin/node
      npm: 10.7.0 - ~/.nvm/versions/node/v18.20.4/bin/npm
      Watchman: 2024.07.29.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.15.2 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 24.0, iOS 18.0, macOS 15.0, tvOS 18.0, visionOS 2.0, watchOS 11.0
    IDEs:
      Android Studio: 2024.1 AI-241.18034.62.2411.12071903
      Xcode: 16.0/16A5211f - /usr/bin/xcodebuild
    npmPackages:
      expo: ~51.0.26 => 51.0.26 
      expo-router: ~3.5.21 => 3.5.21 
      react: 18.2.0 => 18.2.0 
      react-dom: 18.2.0 => 18.2.0 
      react-native: 0.74.3 => 0.74.3 
    Expo Workflow: managed
collinscoder1 commented 1 month ago

What is the last working version? I had the same error too!

77TecShaeer commented 1 month ago

+2

FloppiTuna commented 1 month ago

I was able to downgrade to 1.0.0-rc.12 as a workaround. It’s an older version but it seems to work fine.

On Aug 14, 2024, at 09:37, 77TecShaeer @.***> wrote:

+2

— Reply to this email directly, view it on GitHub https://github.com/cheeriojs/cheerio/issues/4005#issuecomment-2288967956, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIM3YKVA2OSCKQVSJVIXVJLZRNTSBAVCNFSM6AAAAABMMP27C6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBYHE3DOOJVGY. You are receiving this because you authored the thread.

juanmigdr commented 3 weeks ago

Same here, I get the exact same issue in react native: The package at "node_modules/cheerio/dist/commonjs/index.js" attempted to import the Node standard library module "node:stream". It failed because the native React runtime does not include the Node standard library.