Skip to content

🐛 npm package not working as constructor #27

@iArmanKarimi

Description

@iArmanKarimi

Description

When trying to use guardian-js in Node ESM, the import does not provide a usable constructor. Attempting to do new GuardianClient(apiKey, false) throws:

TypeError: GuardianClient is not a constructor

Steps to Reproduce

  1. Install guardian-js via npm
  2. Use ESM import in Node 22+:
import GuardianClient from "guardian-js";
const guardian = new GuardianClient(apiKey, false);
  1. Run node index.js

Expected Behavior

guardian should be an instance of the Guardian client.

Actual Behavior

TypeError: GuardianClient is not a constructor

Notes / Analysis

  • Logging the imported object shows: { default: [class Client] }
  • The default export appears to be the class, but import or destructuring does not work correctly.
  • Likely cause: the package does not properly support ESM or Node 22+.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions