Skip to content

DeprecationWarning: The 'punycode' module is deprecated in Node.js #15358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
Hellnight2005 opened this issue Apr 16, 2025 · 3 comments
Open
2 tasks done
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.

Comments

@Hellnight2005
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.13.2

Node.js version

22.13.1

MongoDB server version

6.15.0

Typescript version (if applicable)

No response

Description

When using Mongoose, Node.js throws a deprecation warning related to the internal use of the punycode module.

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

Steps to Reproduce

  1. Create a simple Node.js app that uses Mongoose.
  2. Run the app using a modern Node.js version (v22.13.1).
  3. Observe the warning in the terminal.

This happens because Node.js has officially deprecated the punycode module as mentioned in their documentation:

🔗Node Docs
But it seems that Mongoose (or one of its dependencies) is still using punycode through Node's core modules, which causes this warning.

Steps to Reproduce

link to the project

Expected Behavior

No response

@vkarpov15
Copy link
Collaborator

I'm unable to repro, running the following script:

'use strict';

const mongoose = require('mongoose');

mongoose.connect('mongodb://127.0.0.1:27017/mongoose_test').then(() => {
  console.log('Connected', mongoose.version, process.version);
});

Gives me the following output:

$ node ./gh-15358.js
Connected 8.13.2 v22.12.0

Try using node --trace-deprecation?

@vkarpov15 vkarpov15 added the can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. label Apr 21, 2025
@KeniaNya
Copy link

KeniaNya commented May 1, 2025

I have the same warning when using the library

$ node --trace-deprecation index.js
(node:9872) [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:399:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:338:10)
at loadBuiltinModule (node:internal/modules/helpers:112:7)
at Function._load (node:internal/modules/cjs/loader:1100:17)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
at Module.require (node:internal/modules/cjs/loader:1340:12)
at require (node:internal/modules/helpers:138:16)
at Object. (C:\myProjects\myMongoDBApplication\node_modules\node-fetch\node_modules\whatwg-url\lib\url-state-machine.js:2:18)

Using mongoose 8.14.1
Node version 22.12.0

@Hellnight2005
Copy link
Author

Hellnight2005 commented May 1, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
Projects
None yet
Development

No branches or pull requests

3 participants