node icon indicating copy to clipboard operation
node copied to clipboard

TypeError: IPinfoWrapper is not a constructor when building a SvelteKit app

Open gtnbssn opened this issue 2 years ago • 1 comments

My SvelteKit app works fine in dev mode.

However when i attempt to build, i get TypeError: IPinfoWrapper is not a constructor. My code looks like this:

import IPinfoWrapper from 'node-ipinfo';
import { IPINFO_TOKEN } from "$env/static/private";

const ipinfoWrapper = new IPinfoWrapper(IPINFO_TOKEN);

const IPinfos = await ipinfoWrapper.lookupIp(requestIP);

The full version in my wip is here if that helps: https://github.com/gtnbssn/lEmplacementExactDuCoeur/blob/main/src/routes/api/connect/%2Bserver.ts

I have found a very similar previous issue here: https://github.com/ipinfo/node/issues/44

It doesn't help though.

Is there a typescript setting I need to change maybe?

gtnbssn avatar Mar 09 '23 04:03 gtnbssn

It works if I import like this:

import { IPinfoWrapper } from 'node-ipinfo';

gtnbssn avatar Mar 09 '23 05:03 gtnbssn