Skip to content

fix(linkedom-crawler): declare cheerio as a dependency#3620

Merged
B4nan merged 1 commit intov4from
fix/linkedom-missing-cheerio-dep
Apr 30, 2026
Merged

fix(linkedom-crawler): declare cheerio as a dependency#3620
B4nan merged 1 commit intov4from
fix/linkedom-missing-cheerio-dep

Conversation

@B4nan
Copy link
Copy Markdown
Member

@B4nan B4nan commented Apr 30, 2026

Summary

packages/linkedom-crawler/src/internals/linkedom-crawler.ts imports cheerio (import * as cheerio from 'cheerio') but @crawlee/linkedom's package.json doesn't list it as a dependency.

It works inside the monorepo because cheerio is hoisted to the workspace root via other packages (@crawlee/cheerio, @crawlee/utils, @crawlee/http, …), so Node always finds it. Downstream installs that depend only on crawlee (which re-exports @crawlee/linkedom) and don't pull any cheerio-using sibling fail at runtime:

Error: Cannot find package 'cheerio' imported from .../node_modules/@crawlee/linkedom/internals/linkedom-crawler.js

This bit the apify-sdk-js v4 catch-up PRs (apify/apify-sdk-js#597) on a clean CI install — without this fix, every consumer has to ship a cheerio dev-dep workaround.

The fix is one-line: declare cheerio: "^1.0.0" (matching what @crawlee/cheerio already pins).

`linkedom-crawler.ts` does `import * as cheerio from 'cheerio'`, but
`cheerio` was not declared in `@crawlee/linkedom`'s dependencies. The
package built/published fine because cheerio is hoisted to the
crawlee monorepo root via other workspaces (`@crawlee/cheerio`,
`@crawlee/utils`, `@crawlee/http`, etc.), so resolution always found
it during dev.

Downstream installs that don't pull any of those packages — e.g. an
SDK that depends only on `crawlee` and re-exports `@crawlee/linkedom`
through it — fail at runtime with `Cannot find package 'cheerio'`
the moment Node resolves the import. Declaring cheerio explicitly
makes the package self-contained.
@B4nan B4nan merged commit b854f5b into v4 Apr 30, 2026
6 checks passed
@B4nan B4nan deleted the fix/linkedom-missing-cheerio-dep branch April 30, 2026 18:01
B4nan added a commit to apify/apify-sdk-js that referenced this pull request Apr 30, 2026
`@crawlee/linkedom@4.0.0-beta.51` now declares cheerio as a direct
dependency (apify/crawlee#3620), so the SDK no longer has to ship its
own cheerio devDep to mask the missing declaration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants