#Adding ESM Module

5 messages · Page 1 of 1 (latest)

ivory vortex
#

Hi, I am trying to add https://github.com/apify/got-scraping, but it's ESM only.

I tried

let gotScraping;

async function fetchWithGotScraping(url) {
    gotScraping ??= (await import('got-scraping')).gotScraping;

    return gotScraping.get(url);
}

But it's not working. Im just getting Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in

Any ideas how?

Thanks

lean goblet
#

Have you tried putting moduleResolution in the tsconfig.json ?

#

something like this: "moduleResolution": "node16" or "moduleResolution": "nodenext"

ivory vortex
#

Thanks! i was able to finally make it work. It's a lot of repetitive work but it finaly worked 😃 Had to do that, put modules in package.json, and changed how i do imports 😃