# TypeError: “x is not a constructor”

> TypeError: x is not a constructor. Usually a default versus named import mixup, a .default from CommonJS interop, an arrow function, or new on a function.

Canonical: https://app369.com/fix/is-not-a-constructor/
Last updated: 2026-11-08

Code that runs new Something() fails with TypeError: Something is not a constructor (or something.default is not a constructor, or _x.Client is not a constructor in bundled code). The value you called new on exists, but it is not a class or constructor function. Most often it is the wrong thing from an import.

**Short answer**

Log the value right before new: console.log(typeof Something, Something). If it is an object with a default or a named key, you imported the module object instead of the class: switch between import Something from and import { Something } from, or use .default when loading an ES module through require. If it is undefined, the export name is wrong. If it is a function, it may be an arrow function or a factory that must be called without new.

## **Why the value is not a constructor, and the fix**

1. 01 ### **Default import versus named import**
  > “There was an attempt to use an object or a variable as a constructor, but that object or variable is not a constructor.” [**MDN, TypeError: x is not a constructor**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor) A library that exports export class Client cannot be loaded with import Client from, and one with export default class cannot be loaded with { Client }. Check the library’s docs or its type definitions for which one it is.```
// library: export class Client {}
import { Client } from 'some-sdk';
const client = new Client();

// library: export default class Client {}
import Client from 'some-sdk';
```
2. 02 ### **CommonJS and ES module interop** require() of a package that was compiled from ES modules returns an object, and the class sits on .default. Bundlers and TypeScript without esModuleInterop show the same thing the other way round. Use the property that actually holds the class.```
const mod = require('some-sdk');
const Client = mod.default ?? mod.Client ?? mod;
const client = new Client();
```
3. 03 ### **An arrow function or a method** Arrow functions, async functions, generators and object methods written with the short syntax cannot be used with new. Write a class, or a regular function, if it really is meant to be constructed.```
// TypeError: Car is not a constructor (the arrow function is the problem)
const Car = (make) => { this.make = make; };

class Car {
  constructor(make) { this.make = make; }
}
```
4. 04 ### **A factory function called with new** Many libraries hand you a function that returns an instance, such as createClient(), express() or axios.create(). Call it without new.```
import { createClient } from '@supabase/supabase-js';
const supabase = createClient(url, key); // no new
```

Checked against the vendor’s docs on November 8, 2026: [MDN: TypeError: x is not a constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor).

## **Rather hand it over?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [from $450**App Fix Ticket**One reproducible bug in an existing mobile or web app, diagnosed and fixed.**See scope and start**](https://app369.com/fixed-price/flutter-firebase-bug-fix/)
- [from $450**AI-Built App Rescue**A Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.****No issues worth fixing, no charge.**** If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.**See scope and start**](https://app369.com/fixed-price/ai-app-rescue/)

Related: [**TypeError: “x is not a function”**](https://app369.com/fix/javascript-is-not-a-function/) · [**Node.js ERR_REQUIRE_ESM**](https://app369.com/fix/node-err-require-esm/) · [**“require is not defined”**](https://app369.com/fix/require-is-not-defined/)

Questions

## **More on this error**

<details>

<summary>**It works locally and fails after building. Why? **+</summary>

The bundler resolved a different build of the package (ESM versus CommonJS) for production. Log the imported value in the built code; the fix is usually the import style or .default.

</details>

<details>

<summary>**Why does it say _x.default is not a constructor? **+</summary>

Compiled code is reading .default from a module that has no default export. Switch to a named import, or enable esModuleInterop in TypeScript if the package is CommonJS.

</details>

<details>

<summary>**Can you fix it for me? **+</summary>

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

</details>

A different error?

## **Describe it and get a written quote**

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.

[**Describe your problem **→](https://app369.com/contact/) [**All fixes**](https://app369.com/fix/)