microlinkhq / metascraper

Get unified metadata from websites using Open Graph, Microdata, RDFa, Twitter Cards, JSON-LD, HTML, and more.
https://metascraper.js.org
MIT License
2.35k stars 168 forks source link

JSDOM dependency is not compatible with node v14 #652

Closed Hereward closed 1 year ago

Hereward commented 1 year ago

All versions of metascraper above v5 have a jsdom v22 dependency which is not compatible with Node v14, which is the highest version compatible with MeteorJS.

Is there some way we can install metascraper@5 with a lower version of JSDom?

The latest versions of jsdom require Node.js v16 or newer. (Versions of jsdom below v22 still work with previous Node.js versions, but are unsupported.)

Kikobeats commented 1 year ago

Hello, consider to use pnpm overrides 🙂

Hereward commented 1 year ago

Thanks for the feedback, I will try it.

Hereward commented 1 year ago

pnpm looks like a good solution for local development, but deployment of MeteorJS apps requires a separate build process on the server using 3rd party tools and a docker image. As I understand, it would require a re-write of the "Meteor-up" code and a new docker image. This may be possible but looks like overkill to solve a single small issue.

I would be interested to hear of anyone who has an elegant solution for MeteorJS. Otherwise I'll have to wait until they support Node v16.

Kikobeats commented 1 year ago

Noted node14 is a non-maintained version at this moment, it's kind of old

CleanShot 2023-08-12 at 09 12 54@2x
Hereward commented 1 year ago

Thanks for your feedback. I wonder if you could help me with one small thing. I currrently have metascraper running on my server at 5ep.net, running Meteor on Node v14. The metascraper package version is ^5.29.8.

Everything is working fine there.

Recently I tried to upgrade to the latest metascraper release (v5.35). This is when I started getting various errors. I then tried to downgrade my installation but the problems persisted. In fact every release above v5 seems to fail now, which is weird, because I've been using these packages for years on Node installations <16.

I'm confused as to why the earlier packages have now also become incompatible. It seems to have something to do with the @Metascraper/helpers package which is installed automatically when any metascraper package is installed. @Metascraper/helpers always gets installed at the latest version even when installing lower versions of Metascraper. I've tried to install a lower version of this package too (@metascraper/helpers@5.14.12) which doesn't use jsdom. This installation works perfectly, but I get runtime errors when I require metascraper:

The "superCtor.prototype" property must be of type object. Received undefined

Any thoughts as to how to downgrade my install would be much appreciated. If I can't find a way to do this I will have to rip out metascraper completely and replace it with another scraping package.

Kikobeats commented 1 year ago

Can you try to print the stack trace? It's hard to help without more details

Hereward commented 1 year ago

UPDATE

I rebuilt the app against an older lock-file and package.json file and everything is working again.

I can now confirm that metascraper v5.29.8 is compatible with MeteorJS v2.x (which runs on Node v14). This version doesn't have jsdom as a dependency.

If you're using this package with Meteor 2.x you need to be careful of minor version upgrades.