IonicaBizau/scrape-it

TypeError: scrape_it_1.default is not a function

Closed this issue · 2 comments

Not sure why I'm getting this error. If I replace the import statement with require it works. Any idea? I think it might be to do with the typings file?

scrapeIt(url, { title: '.mw-headline', });

Can you add an example?

Hi! I know this bug is closed, but my answer may help someone in the future 🔮

When you have this kind of problems, always, the main reason is because you are trying to consume a Common JS dependency in an ES Module environment. In addition, this a very common problem when you are trying to consume a Common JS dependency using Typescript.

The way to solve it is adding in the tsconfig.json file the next row "esModuleInterop": true.

May I help someone some day!

Have a great scrapping 😄