not a constructor 🟨 JavaScript

TypeError: x is not a constructor

new was used with something that isn’t a class/constructor — usually a wrong import.

Seen on: JavaScript

Meaning

Default vs named import mix-ups, arrow functions (which can’t be constructors) and CommonJS/ESM interop return objects instead of classes.

Common causes

  • import Foo from vs import { Foo } from mismatch
  • new on an arrow function
  • CommonJS module exporting { Foo }
  • Circular import returning undefined

⚡ Quick fix

  1. Check the library’s export style
  2. Log the imported value
  3. Use .default for CommonJS interop if needed

Detailed fix by platform

JavaScript

  1. import { Client } from 'pkg'; // not: import Client from 'pkg'

How to diagnose

  1. Import — Named or default?
  2. Value — typeof the imported binding

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.