cheeriojs / cheerio

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

cheerio 1.0.0 breaks bundling of react native #4032

Open UNIDY2002 opened 3 months ago

UNIDY2002 commented 3 months ago

Minimal example: https://github.com/thu-info-community/thu-info-app/actions/runs/10414518614/job/28843638237?pr=587

Error: Unable to resolve module node:stream from /home/runner/work/thu-info-app/thu-info-app/node_modules/cheerio/dist/commonjs/index.js: node:stream could not be found within the project or in these directories:
  ../../node_modules
error Unable to resolve module node:stream from /home/runner/work/thu-info-app/thu-info-app/node_modules/cheerio/dist/commonjs/index.js: node:stream could not be found within the project or in these directories:
  ../../node_modules
  node_modules
  ../../node_modules
  49 | const undici = __importStar(require("undici"));
  50 | const whatwg_mimetype_1 = __importDefault(require("whatwg-mimetype"));
> 51 | const node_stream_1 = require("node:stream");
     |                                ^
  52 | const options_js_1 = require("./options.js");
  53 | const load_parse_js_1 = require("./load-parse.js");
  54 | /**.
  node_modules
  ../../node_modules
  49 | const undici = __importStar(require("undici"));
  50 | const whatwg_mimetype_1 = __importDefault(require("whatwg-mimetype"));
> 51 | const node_stream_1 = require("node:stream");
     |                                ^
  52 | const options_js_1 = require("./options.js");
  53 | const load_parse_js_1 = require("./load-parse.js");
  54 | /**
    at ModuleResolver.resolveDependency (/home/runner/work/thu-info-app/thu-info-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:153:15)
    at DependencyGraph.resolveDependency (/home/runner/work/thu-info-app/thu-info-app/node_modules/metro/src/node-haste/DependencyGraph.js:279:43)
    at /home/runner/work/thu-info-app/thu-info-app/node_modules/metro/src/lib/transformHelpers.js:176:21
    at resolveDependencies (/home/runner/work/thu-info-app/thu-info-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:56:25)
    at visit (/home/runner/work/thu-info-app/thu-info-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:107:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 2)
    at async visit (/home/runner/work/thu-info-app/thu-info-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:116:5)
    at async Promise.all (index 4)
    at async visit (/home/runner/work/thu-info-app/thu-info-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:116:5)

Steps to reproduce:

grahamrb commented 3 months ago

We're using turtle cli to do builds with React Native and error with the new Cheerio 1.0.0 release. There doesn't appear to be a way to change the package.json that turtle uses internally for the React Native build. If anyone has a work around for this please let me know.

hengkx commented 3 months ago

same error

ksharma001 commented 3 months ago

This new tag should've been released with 2.x.x instead of 1.x.x

Auto upgrade from stable 1.0.0-rc.12 to 1.0.0 causes issues due to node version (node:: imports are not supported in node 14)

@grahamrb and to anyone else facing this issue:

I recommend you to ADD FIXED version set to the previous version in your dependencies/devDependencies of package.json so that any internal packages importing this package inherit this from your parent app :

"devDependencies": { "cheerio": "1.0.0-rc.12", }

use below command to verify that any internal dependency is inheriting the package from parent ( in my case it was enzyme )

npm ls cheerio

├── cheerio@1.0.0-rc.12 └─┬ enzyme@3.11.0 └── cheerio@1.0.0-rc.12 deduped

ChristopherGabba commented 3 months ago

I am also experiencing this error when upgrading: iOS Bundling failed 10976ms node_modules/expo/AppEntry.js (4227 modules) 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.

ceebows commented 2 months ago

Reverting to 1.0.0-rc.12 should fix issue

bangdy commented 1 month ago

same issue. I hope to fix this issue