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

TypeError: createMollieClient is not a function #339

Open
DHFW opened this issue Dec 27, 2023 · 1 comment
Open

TypeError: createMollieClient is not a function #339

DHFW opened this issue Dec 27, 2023 · 1 comment
Assignees
Labels
enhancement Improvements and changes outside of API endpoints.

Comments

@DHFW
Copy link

DHFW commented Dec 27, 2023

I had my code like this, what should work according to the docs, using TypeScript:
import createMollieClient, { PaymentStatus } from '@mollie/api-client';

And calling the createMollieClient code like so:

 const mollieClient = createMollieClient({
        apiKey: ...
      });

When using this with babel transpiled to CJS this worked fine (NodeJS 16.x)

I recently updated my project to Node 18.18.0, using ESBuild and ES modules as build output.
At development time, TypeScript was fine with this.

But when running the code, it raised this error: TypeError: createMollieClient is not a function.
After some investigation I saw that the createMollieClient is export as default and as names export, so I tried the import like so:

import {createMollieClient, PaymentStatus } from '@mollie/api-client';

And that worked (notice the named import instead the default export). I has something to do with the way the code is exported and build.

I'm not sure how this is possible, but leaving this here to maybe save others some time...

@Pimm Pimm self-assigned this Jul 9, 2024
@Pimm
Copy link
Collaborator

Pimm commented Jul 9, 2024

Thanks, Didier!

We will look into the optimal experience we can deliver for both CJS and ESM in the future.

@janpaepke janpaepke added the enhancement Improvements and changes outside of API endpoints. label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements and changes outside of API endpoints.
Projects
None yet
Development

No branches or pull requests

3 participants