Skip to content

TypeError: createMollieClient is not a function #339

@DHFW

Description

@DHFW

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...

Metadata

Metadata

Assignees

Labels

enhancementImprovements and changes outside of API endpoints.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions