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

Module punycode is deprecated since Node.js 21 #20

Open
cedx opened this issue Oct 18, 2023 · 10 comments
Open

Module punycode is deprecated since Node.js 21 #20

cedx opened this issue Oct 18, 2023 · 10 comments

Comments

@cedx
Copy link

cedx commented Oct 18, 2023

This library depends on the punycode builtin module... but since Node.js 21, this module is deprecated:

(node:4284) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
@ttys3
Copy link

ttys3 commented Nov 10, 2023

bitwarden/clients#6689 (comment)

solution:

npm install punycode --save
// Replace this:
const punycode = require('punycode');
// With this:
const punycode = require('punycode/');

basically just add a trailing forward slash

@MikeMcC399

This comment was marked as outdated.

@ttys3
Copy link

ttys3 commented Nov 14, 2023

@ttys3

Do you have any logs which show that the npm module tr46 is used by fast-url-parser from this repo?

this is not about tr46. this is just a solution from other repo, and I think it may also works for this repo.

@ttys3
Copy link

ttys3 commented Nov 14, 2023

@MikeMcC399 I came to here because I am using facebook docusaurus.

and @docusaurus/core depends on -> serve-handler which depends on fast-url-parser

@ttys3
Copy link

ttys3 commented Nov 14, 2023

@MikeMcC399 I have updated the content and removed the non-related words

@MikeMcC399
Copy link

@ttys3

I have updated the content and removed the non-related words

Your workaround is for a different module.

@MikeMcC399
Copy link

The issue is reproducible with

git clone https://github.com/petkaantonov/urlparser
cd urlparser
npm install
node --trace-deprecation ./test/index.js

The line of code which needs changing is

var punycode = require("punycode");

and this can be changed to

var punycode = require("punycode/");

The question is now if this repo is still being maintained? @petkaantonov last committed 8 years ago

@ttys3
Copy link

ttys3 commented Nov 17, 2023

I do not think it is actively maintained.

@cedx
Copy link
Author

cedx commented Nov 17, 2023

Why not simply use the url core module?
It supports Puny code thanks to the url.domainToASCII() function.

@MikeMcC399
Copy link

@cedx

Why not simply use the url core module?

The problem is when fast-url-parser is used by another npm module that you have no control over, so it's not really "simple" to change the code in a transitive dependency.

I did however find that using the npm module patch-package it was quite easy to patch fast-url-parser

var punycode = require("punycode");
to change instead to:

var punycode = require("punycode/");

and to save this as a patch which is then re-applied as a postinstall step.

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

3 participants