Skip to content

"DeprecationWarning: The punycode module is deprecated." in Node 22 #331

Description

@remyoudemans

Node version: 22.1.0
@apollo/datasource-rest version: 6.2.2 (latest version at time of writing)

The problem

Since moving to use node 22, we have seen the following deprecation warning:

(node:47562) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:3:9
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:398:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:337:10)
    at loadBuiltinModule (node:internal/modules/helpers:104:7)
    at Module._load (node:internal/modules/cjs/loader:1075:17)
    at Module.require (node:internal/modules/cjs/loader:1310:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/remy.oudemans/Documents/apply-bff/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
    at Module._compile (node:internal/modules/cjs/loader:1480:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)

This will affect everyone using Node 22, which is the Current Node release and will move to LTS on 2024-10-29.

Where it comes from

We have tracked this down to @apollo/datasource-rest using "node-fetch": "^2.6.7" (link) which uses "whatwg-url": "^5.0.0" (link) which uses the deprecated punycode module.

The current version of node-fetch does not depend on whatwg-url at all: https://github.com/node-fetch/node-fetch/blob/v3.3.2/package.json#L64. So updating to that version should fix this warning.

Node-fetch v3 is an ESM-only package, so that may make the update tricky.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions