Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error: QLDB is not a constructor #9

Closed
Salmandabbakuti opened this issue Apr 27, 2020 · 7 comments
Closed

Type error: QLDB is not a constructor #9

Salmandabbakuti opened this issue Apr 27, 2020 · 7 comments

Comments

@Salmandabbakuti
Copy link

Hello @Lepozepo
I set up this module for my project and when I tried to run this example snippet for querying ledger, it shoots me with below error:

Type error: QLDB is not a constructor

are sure QLDB is a constructor? or am I missing something?

@Lepozepo
Copy link
Owner

Hmm, it should just work with import QLDB from 'qldb'. It's definitely the default export in the package. What configuration are you using to run it?

@Salmandabbakuti
Copy link
Author

Salmandabbakuti commented Apr 27, 2020

Thanks for your reply @Lepozepo
I've been using below command to run since it consists es6 imports, I modified my app.js to app.mjs and run like this.

node --experimental-modules app.mjs

Is this the problem?

@Lepozepo
Copy link
Owner

@Salmandabbakuti ah, that's probably it. So the src of the package is built with babel but when you run npm install qldb you're installing a set of prebuilt versions of this package. I think using just node app.js should work but you'll need to make sure to import using the normal require statement as you would without using any kind of compiler.

@Salmandabbakuti
Copy link
Author

@Lepozepo , I tried using require but it still it is throwing that QLDB is not a constructor. Any possible solution?

@Lepozepo
Copy link
Owner

@Salmandabbakuti what do you see when you console.log the variable that's getting imported?

@Salmandabbakuti
Copy link
Author

Salmandabbakuti commented Apr 29, 2020

@Lepozepo
it is now working fine with few modifications. you can check my configuration here

@Lepozepo
Copy link
Owner

Lepozepo commented May 4, 2020

@Salmandabbakuti ah! You had to do require().default awesome. Glad you were able to get it working :D thanks for the mention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants