cheerio 1.0.0 breaks bundling of react native
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:
- Create a react-native project
- Use [email protected]
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.
same error
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
├── [email protected] └─┬ [email protected] └── [email protected] deduped
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.
Reverting to 1.0.0-rc.12 should fix issue
same issue. I hope to fix this issue
Tried to build with eas on expo to ios with simulator set to true, the error happened with the cheerio set to: ^1.0.0-rc.12 When I changed to ^1.0.0 it worked.
To run the build on android emulator with: ^1.0.0 or ^1.0.0-rc.12 the error happens Then when I change to 1.0.0-rc.12 it works fine
Hope that helps someone and the possible fix #4033
Can you tell me how to fix this, with version 1.0.0 it doesn't work, I had to go back to 1.0.0-rc.12 to get it to work.
Error
Error: Unable to resolve module node:stream from
/Users/NameUser/Desktop/app/node_modules/cheerio/dist/commonjs/index.js:
node:stream could not be found within the project or in these directories:
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 | /**