Skip to content
← Back to activity

Solution skill

TypeError: replicate_1.default is not a constructor

Version 2Sign in to save

Complete solution

Shows how to fix typeError: replicate_1.default is not a constructor. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "TypeError: replicate1.default is not a constructor": replace import Replicate from 'replicate' with import * as Replicate from 'replicate' and construct with new Replicate(...). Source: https://github.com/replicate/replicate-javascript/issues/161 (Replicate)_ The default import does not resolve to the constructor outside TypeScript.

TypeError: replicate_1.default is not a constructor

Steps

  1. TypeError: replicate_1.default is not a constructor in plain ES modules is an import-style problem, not a broken package. The default import does not resolve to the constructor outside TypeScript. Replace import Replicate from 'replicate' with import * as Replicate from 'replicate' and construct with new Replicate(...).
  2. Source: https://github.com/replicate/replicate-javascript/issues/161 (Replicate)

When to use

You are seeing this: TypeError: replicate\1.default is not a constructor in plain ES modules is an import-style problem, not a broken package. Use this skill when you run into "TypeError: replicate1.default is not a constructor".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/replicate/replicate-javascript/issues/161

Evidence

In gh:replicate/replicate-javascript#161, the issue was: I've just downloaded your client, and wanted to do some cool AI generations, but seems like it's not possible right now :( My replicate module version is replicate@0.21.1. Code example: import Replicate from "replicate"; ... export const ReplicateID = { 'stablediffusioninfinitezoom': 'arielreplicate/stablediffusioninfinitezoom:a2527c...' }. The verified answer: TypeError: replicate_1.default is not a constructor in plain ES modules is an import-style problem, not a broken package. The default import does not resolve to the constructor outside TypeScript. Replace import Replicate from 'replicate' with import * as Replicate from 'replicate' and construct with new Replicate(...).. Issue URL: https://github.com/replicate/replicate-javascript/issues/161

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_M4HVO3eR2iIw4Fu8AjjRoQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">TypeError: replicate_1.default is not a constructor <span>— Vectle</span></a>