Skip to content
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

Node.js 22: "[DEP0040] DeprecationWarning: The punycode module is deprecated." when using npm module serve #802

Closed
MikeMcC399 opened this issue Apr 25, 2024 · 23 comments

Comments

@MikeMcC399
Copy link

MikeMcC399 commented Apr 25, 2024

Description

Running serve under Node.js 22.x version causes a deprecation notice similar to the following to be displayed:

$ serve -v
(node:3752) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
14.2.2

Node.js v22.0.0 (Current) was released on Apr 24, 2024.

Steps to reproduce

On Ubuntu 22.04.4 LTS with Node.js v22.0.0
On Ubuntu 22.04.5 LTS with Node.js v22.9.0

npm install serve@latest -g
export NODE_OPTIONS='--trace-deprecation'
serve -v

shows

$ serve -v
(node:4155) [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:113:7)
    at Module._load (node:internal/modules/cjs/loader:1053:17)
    at Module.require (node:internal/modules/cjs/loader:1290:19)
    at require (node:internal/modules/helpers:188:18)
    at Object.<anonymous> (/home/mike/n/lib/node_modules/serve/node_modules/fast-url-parser/src/urlparser.js:401:16)
    at Module._compile (node:internal/modules/cjs/loader:1455:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1534:10)
14.2.2

Library version

14.2.2 and 14.2.3

Node version

v22.0.0 and v22.9.0

@MikeMcC399
Copy link
Author

@nemanjacosovic
Copy link

Probably not worth the mention, but yes it's present in node v22.5.0.

(node:96621) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

@MikeMcC399
Copy link
Author

@nemanjacosovic

I've updated the original posting with the latest versions serve 14.2.3 / Node.js v22.5.1.

@MikeMcC399
Copy link
Author

MikeMcC399 commented Oct 15, 2024

"serve-handler": "6.1.5",

@MikeMcC399
Copy link
Author

@ArmanTheFirst
Copy link

I'm struggling with this problem in a Next.js 14 project. The warning appears whenever my dev server via npm run dev is running. My node version is 22.8.0. Still didn't find a fix yet...

@MikeMcC399
Copy link
Author

@ArmanTheFirst

Does your error come from vercel/serve or from another module?

The following may give you additional debug information:

export NODE_OPTIONS='--trace-deprecation'
npm run dev

The following will tell you if you have vercel/serve installed, and which version. If it shows (empty) then you don't have vercel/serve installed:

npm ls serve

@ArmanTheFirst
Copy link

@MikeMcC399

It seems to be coming from another module, as vercel/serve doesn't appear to be installed (it showed empty for npm ls serve). This came after tracing the deprecation:

(node:35377) [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:108:7) at Module._load (node:internal/modules/cjs/loader:1099:17) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12) at mod.require (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/server/require-hook.js:65:28) at require (node:internal/modules/helpers:135:16) at 477 (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:104564) at __nccwpck_require__ (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:453905) at 11 (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:83776) at __nccwpck_require__ (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:453905) at 429 (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:78058) at __nccwpck_require__ (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:453905) at 943 (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:80579) at __nccwpck_require__ (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:453905) at 346 (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:83438) at __nccwpck_require__ (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:453905) at 193 (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:48306) at __nccwpck_require__ (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:453905) at /Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:454076 at Object.<anonymous> (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/node-fetch/index.js:1:454119) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12) at mod.require (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/server/require-hook.js:65:28) at require (node:internal/modules/helpers:135:16) at Object.<anonymous> (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/@next/font/dist/google/fetch-css-from-google-fonts.js:8:38) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12) at mod.require (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/server/require-hook.js:65:28) at require (node:internal/modules/helpers:135:16) at Object.<anonymous> (/Users/arman/.../nextjs-stream-chat/node_modules/next/dist/compiled/@next/font/dist/google/loader.js:34:39) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)

@MikeMcC399
Copy link
Author

MikeMcC399 commented Dec 8, 2024

@ArmanTheFirst

vercel/serve doesn't appear to be installed (it showed empty for npm ls serve).

In that case you are in the wrong issue list for your problem. Unfortunately I couldn't see where it's coming from in your logs. They seem to have lost their formatting, so are very difficult to read. See if you can identify any module in the logs which you have installed, and check the corresponding repo issue list to see if DEP0040 has been reported there and if there is a newer version with a fix available.

Also, the following should help:

npm ls punycode

Good luck!

@ArmanTheFirst
Copy link

@MikeMcC399

I'm still very thankful for your help and advice which got me closer towards a solution!! Will see what's the best thing I can do. I'll see if the error logs can give me some more information about the module it's originating from. I already tried npm ls punycode:

└─┬ eslint@9.16.0 invalid: "^8" from the root project, "^7.23.0 || ^8.0.0" from node_modules/eslint-config-next └─┬ ajv@6.12.6 └─┬ uri-js@4.4.1 └── punycode@2.3.1

Let me play around with it and find options...

@alessiotortora
Copy link

@MikeMcC399

I'm still very thankful for your help and advice which got me closer towards a solution!! Will see what's the best thing I can do. I'll see if the error logs can give me some more information about the module it's originating from. I already tried npm ls punycode:

└─┬ eslint@9.16.0 invalid: "^8" from the root project, "^7.23.0 || ^8.0.0" from node_modules/eslint-config-next └─┬ ajv@6.12.6 └─┬ uri-js@4.4.1 └── punycode@2.3.1

Let me play around with it and find options...

did you find a solution ?

@ArmanTheFirst
Copy link

@alessiotortora
In the mean I focused on new project with Next.js 15, where I also encountered the warning. There I made sure to use npm i punycode --save and after that I didn't see the log again. In the other project though it didn't work but by this time I had pretty much messed that one up

@4Bud20
Copy link

4Bud20 commented Jan 28, 2025

hi ! I have encountered this problem in the installation of my script js : Chargement des pools Raydium...
(node:18820) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
Erreur lors du chargement des pools : Cannot read properties of undefined (reading '4')
I cannot find the issue (punycode@2.3.1) and (@raydium-io/raydium-sdk@1.3.1-beta.58) if someone have an answer, thanks !

@Adiiieee
Copy link

Node.js is planning to remove this built-in module from its standard library so you can you third-party library for this:
npm install -D punycode should solve the problem.

@4Bud20
Copy link

4Bud20 commented Jan 29, 2025

thank's for your answer ! but the issue keep coming ... (node:1759) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. any way I try, I end up with this message..

@MikeMcC399
Copy link
Author

@4Bud20

https://www.npmjs.com/package/@raydium-io/raydium-sdk?activeTab=dependencies shows that it does not depend on serve so this is the wrong repo to be asking for help with @raydium-io/raydium-sdk.

The repo https://github.com/raydium-io/raydium-sdk is archived and so there will be no fixes from them. I would suggest that you search in the raydium-io community for a resolution. I cannot help you further with this.

@MikeMcC399
Copy link
Author

Attention: serve only!

The issue [DEP0040] DeprecationWarning: The punycode module is deprecated here in this repository is for the npm module serve only!

If you are using serve and you are experiencing this problem, make sure that you update to minimum serve@14.2.4.

If you are not using serve then you are in the wrong place to report a problem or request help for the above warning. Please do not add comments for issues with other npm modules!

@MikeMcC399
Copy link
Author

@AndyBitz
Can I ask you to lock this issue which is already resolved? It is attracting posts for unrelated npm modules.

@4Bud20
Copy link

4Bud20 commented Jan 30, 2025

Ho ! sorry, I'm a beginner ! thank's for your time and have a good one !

@RikyAdiPutra
Copy link

hi, everyone, i find problem when npm run build in my project
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
Generating static pages (20/28) [ ==]{ status: false, value: null }
✓ Generating static pages (28/28)
✓ Collecting build traces
✓ Finalizing page optimization
how to solve this error ?

@MikeMcC399 MikeMcC399 changed the title Node.js 22: "[DEP0040] DeprecationWarning: The punycode module is deprecated." Node.js 22: "[DEP0040] DeprecationWarning: The punycode module is deprecated." when using npm module serve Feb 19, 2025
@MikeMcC399
Copy link
Author

@Lermatroid

If anyone else is running into this and using @google-analytics/data is is the library that is causing the issue.

This issue list is only for problems with the npm module serve, not for the error message caused by other npm modules like @google-analytics/data.

@Lermatroid
Copy link

@MikeMcC399 Oops my bad. I had a bunch of tabs open trying to debug this and commented on the wrong one. I deleted the comment. Thanks for the heads up!

@MikeMcC399
Copy link
Author

#802 (comment) asks users not to comment in this issue regarding the error message caused by modules other than serve.

If you are reading this and you are not using serve, then you should know that later versions of Node.js, such as Node.js v22.14.0 have stopped showing this deprecation message. So I would recommend updating your Node.js version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants