cheeriojs / cheeriojs/cheerio

Module parse error after upgrading from cheerio v1.0.0-rc.12 to v1.0.0 in Nuxt (Webpack 4) environment

Open
#4,459 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
30.5k
Forks
1.7k
Avg merge
5h
Merged PRs (30d)
71

Description

## Description
After upgrading `cheerio` from **v1.0.0-rc.12** to **v1.0.0**, I started seeing module parse errors in my Nuxt project. Reverting back to `v1.0.0-rc.12` fixes the issue, so it seems specific to `v1.0.0`.

## Error Logs
```
ERROR in /home/cooperwang/projects/web-project/node_modules/.pnpm/node_modules/encoding-sniffer/dist/commonjs/index.js Module not found: Error: Can't resolve 'node:stream' in '/home/cooperwang/projects/web-project/node_modules/.pnpm/node_modules/encoding-sniffer/dist/commonjs'

ERROR in /home/cooperwang/projects/web-project/node_modules/.pnpm/node_modules/parse5-parser-stream/dist/index.js Module not found: Error: Can't resolve 'node:stream' in '/home/cooperwang/projects/web-project/node_modules/.pnpm/node_modules/parse5-parser-stream/dist'

ERROR in ./node_modules/cheerio/dist/esm/index.js Module not found: Error: Can't resolve 'node:stream' in '/home/cooperwang/projects/web-project/sites/w12/node_modules/cheerio/dist/esm'

ERROR in /home/cooperwang/projects/web-project/node_modules/.pnpm/node_modules/undici/index.js 123:39 Module parse failed: Unexpected token (123:39) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See
https://webpack.js.org/concepts#loaders
```

## Steps to Reproduce
1. Install or upgrade to `cheerio@1.0.0` in a Nuxt 2 project using Webpack 4.
2. Run `pnpm run dev` or `pnpm run build`.
3. Observe the module parse errors above.

## Expected Behavior
The build should succeed without errors, as it does when using `cheerio@1.0.0-rc.12`.

## Environment
- **Operating System**: Linux
- **Node Version**: v20.12.2
- **Nuxt Version**: 2.17.4
- **CLI Version**: 3.22.5
- **Nitro Version**: -
- **Package Manager**: pnpm@9.14.4
- **Builder**: webpack 4.47.0
- **User Config**: -
- **Runtime Modules**: -
- **Build Modules**: -

## Additional Context
- The error only appears after upgrading to `cheerio@1.0.0`.
- Downgrading to `cheerio@1.0.0-rc.12` resolves the issue.

Any guidance or workaround would be greatly appreciated. Thank you!

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in a Nuxt 2.17.4 project with Webpack 4.47.0 and cheerio@1.0.0, then compare it with v1.0.0-rc.12. Inspect the reported dependency entry points in encoding-sniffer/dist/commonjs/index.js, parse5-parser-stream/dist/index.js, cheerio/dist/esm/index.js, and undici/index.js. Done means the Nuxt dev or build command succeeds after the compatibility issue is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, nuxt, webpack
Domain
build-system, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.