You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
I can't import IPinfoWrapper. IPinfoWrapper is undefined #44
First of all I wanted to say that I just created a new project in nest.js so i am using typescript instead of javascript.
I ran npm install node-ipinfo
And then I created a service that returns the city via IP:
import IPinfoWrapper from 'node-ipinfo';
import { Injectable } from '@nestjs/common';
@Injectable()
export default class IpInfoProvider {
getCity(): string {
console.log(IPinfoWrapper);
const ipinfoWrapper = new IPinfoWrapper('token');
return 'city-name-test';
}
}
As you can see, I'm logging the IPinfoWrapper imported class, but I'm getting undefined, this means that when instantiating I get the following error: TypeError: node_ipinfo_1.default is not a constructor
The only way I'm able to instantiate the IPinfoWrapper is to go to the node_modules/node-ipinfo/index.js file and change the return
But this could have something to do with not properly detecting ES modules, as the index.js you modified above was not being generated by typescript itself, and we may have missed a spot somehow somewhere.
I've pushed a 3.0.0 version which makes it so we use a typescript-generated index.js file. Can you upgrade and try again?
Activity
UmanShahzad commentedon Sep 10, 2021
I've tried reproducing this in a fresh TypeScript project and I can't seem to. https://github.com/ipinfo/node/blob/master/test-app/ipinfo.ts
But this could have something to do with not properly detecting ES modules, as the
index.jsyou modified above was not being generated by typescript itself, and we may have missed a spot somehow somewhere.I've pushed a
3.0.0version which makes it so we use a typescript-generatedindex.jsfile. Can you upgrade and try again?nuno-cunha-dev commentedon Sep 11, 2021
Thank you very much.
With the new version(3.0.0) everything works fine.