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
- Check the library’s export style
- Log the imported value
- Use .default for CommonJS interop if needed
Detailed fix by platform
JavaScript
import { Client } from 'pkg'; // not: import Client from 'pkg'
How to diagnose
- Import — Named or default?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026