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

Cannot read property 'DOCUMENT_MODE' of undefined #551

Closed 6696ram closed 2 years ago

6696ram commented 2 years ago

Prerequisites

Cannot read property 'DOCUMENT_MODE' of undefined

I am getting the link using got or fetch when passed to the metascraper Object to get the data, it is giving the above mentioned error

const {
            body: html,
            url
        } = await got(targetUrl)
        const metadata = await metascraper({
            html,
            url
        })
        console.log(metadata) 

#

Kikobeats commented 2 years ago

Sorry, but I can't reproduce the issue with this information.

You should to follow the issue template and create a reproducible example using https://npm.runkit.com/metascraper

6696ram commented 2 years ago

@Kikobeats I was using node version 12 This was because of the parse5 package which metascraper internally uses, Installing the parse5 package explicitly worked for me