Skip to content

[DEP0040] DeprecationWarning for punycode through node-fetch 2.x.x #479

@lonelyelk

Description

@lonelyelk

Describe the bug

When running node 22, the deprecation warning appears as soon as the library is required.

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

This is due to this dependency chain:

└─┬ @okta/okta-sdk-nodejs@8.0.0
  └─┬ node-fetch@2.7.0
    └─┬ whatwg-url@5.0.0
      └── tr46@0.0.3

Reproduction Steps?

Node suppresses deprecation warnings when the deprecated code is ran from inside node_modules. To reproduce the behavior you need to create a bundle (e.g., using esbuild). For example, create a file repro-punycode.js:

const { Client } = require("@okta/okta-sdk-nodejs");

Build it using esbuild and run:

npx esbuild repro-punycode.js --bundle --platform=node --target=node22 --outfile=repro-bundle.js
node repro-bundle.js

The outcome:

(node:PID) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

SDK Versions

  System:
    OS: macOS 26.3.1
    CPU: (16) arm64 Apple M3 Max
    Memory: 1.31 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.16.0 - /Users/username/.asdf/installs/nodejs/22.16.0/bin/node
    Yarn: 1.22.22 - /Users/username/.asdf/installs/nodejs/22.16.0/bin/yarn
    npm: 10.9.2 - /Users/username/.asdf/plugins/nodejs/shims/npm
    pnpm: 10.32.1 - /Users/username/.asdf/installs/nodejs/22.16.0/bin/pnpm
  Browsers:
    Chrome: 146.0.7680.80
    Firefox: 148.0.2
    Safari: 26.3.1
  npmPackages:
    @okta/okta-sdk-nodejs: ^8.0.0 => 8.0.0

Additional Information

The solution, as described in node-fetch/node-fetch#1826 is to bump the major version of node-fetch.

Also this is an STDERR output, so it's rather noisy in logs.

Also my system is irrelevant, as it runs in an AWS Lambda. The key versions are: SDK 8.0.0 and node 22. Everything else can be anything else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions