Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cheerio.default is undefined in newest release #109

Closed
AlexanderPico opened this issue Aug 12, 2024 · 5 comments · May be fixed by #110
Closed

cheerio.default is undefined in newest release #109

AlexanderPico opened this issue Aug 12, 2024 · 5 comments · May be fixed by #110

Comments

@AlexanderPico
Copy link

After a couple years of working just fine, we're now seeing this error when attempting svg-to-png conversions...

TypeError: Cannot read properties of undefined (reading 'html')
    at [convert] (/home/runner/work/wikipathways-database/wikipathways-database/wikipathways-database/scripts/generate-svgs/node_modules/convert-svg-core/src/Converter.js:264:33)

https://github.com/neocotic/convert-svg/blob/main/packages/convert-svg-core/src/Converter.js#L264
That line is...

const svg = cheerio.default.html(this[_sanitize](cheerio.load(input, null, false)('svg:first'), options));

Why would cheerio.default be undefined suddenly?

@AlexanderPico
Copy link
Author

AlexanderPico commented Aug 12, 2024

Might be related to breaking changes in cheerio: https://github.com/cheeriojs/cheerio/releases. But convert-svg-core specifies v1.0.0-rc.11, so the release from 3 days ago shouldn't matter, right?

@AlexanderPico
Copy link
Author

AlexanderPico commented Aug 12, 2024

Indeed, the cheerio.default.html line works fine in v1.0.0-rc.11, but breaks with the new release of cheerio v.1.0.0. The older rc version is already specified, but is being ignored or overridden?

Is it because of the rc syntax... or does it need to be in overrides or resolutions?

@AlexanderPico
Copy link
Author

Ah, apparently other packages depending on cheerio have suffered the same issue. The solution may indeed to be to force an override... cheeriojs/cheerio#3993

@AlexanderPico AlexanderPico changed the title cheerio.default is undefined cheerio.default is undefined in newest release Aug 13, 2024
@AlexanderPico
Copy link
Author

Adding this to my package.json seemed to fix the issue:


  "pnpm": {
    "overrides": {
      "cheerio": "1.0.0-rc.11"
    }

@DrRefactor
Copy link

should this really be closed? Instead of hardcoding cheerio version resolution in projects, it should be hardcoded inside this lib.

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 a pull request may close this issue.

2 participants