Skip to content

Module '".../node_modules/zod/index"' has no default export. import type z from 'zod'; #1032

@enricrp-rea

Description

@enricrp-rea

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • This is an issue with the Node library

Describe the bug

I am programming an assistant using the openai library but when trying to build my code it gives the following error.

../../node_modules/openai/helpers/zod.d.ts:2:13 - error TS1192: Module '"../node_modules/zod/index"' has no default export.

2 import type z from 'zod';
              ~

  ../../node_modules/zod/index.d.ts:1:1
    1 export * from "./lib";
      ~~~~~~~~~~~~~~~~~~~~~~
    'export *' does not re-export a default.

[3:27:12 PM] Found 1 error. Watching for file changes.

Shouldn't it be better to import only the necessary types from zod instead of all types?

import type { infer as _infer, ZodType } from 'zod';

This way, it would benfit tree-shaking as we are only importing what we need.

To Reproduce

  1. Install the openai library
  2. Build node in watch mode

Code snippets

No response

OS

Ubuntu

Node version

v20.15.0

Library version

openai v4.56.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions