Skip to content

Node 22: DeprecationWarning: The punycode module is deprecated. #1148

@Mathias-S

Description

@Mathias-S

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

Importing and using openai in the current LTS version of Node (v22) will give the following warning:

DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

To Reproduce

  1. Use the current LTS version of Node (v22)
  2. Import the openai package and use it in any way, e.g.
import openai from "openai"; 
console.log(typeof openai);
  1. Run the code. Node will log the aforementioned warning.

The expected behaviour is that the openai works without warnings in the current LTS version of Node.

There is no warning in older LTS versions of Node such as Node v18 and Node v20. However, as of this week, those are now in maintenance mode.

There are previous issues (#527 #750 #780) and a PR (#402) addressing this, but they have all been closed without any resolution or any new issues tracking the progress.

The root cause is the usage of node-fetch@2.7.0.

Code snippets

No response

OS

macOS

Node version

Node v22

Library version

openai v4.68.4

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