urlparser icon indicating copy to clipboard operation
urlparser copied to clipboard

Module `punycode` is deprecated since Node.js 21

Open cedx opened this issue 2 years ago • 10 comments

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.

cedx avatar Oct 18 '23 17:10 cedx

https://github.com/bitwarden/clients/issues/6689#issuecomment-1786252068

solution:

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

basically just add a trailing forward slash

ttys3 avatar Nov 10 '23 06:11 ttys3

@ttys3

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

MikeMcC399 avatar Nov 14 '23 01:11 MikeMcC399

@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 avatar Nov 14 '23 02:11 ttys3

@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 avatar Nov 14 '23 02:11 ttys3

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

ttys3 avatar Nov 14 '23 02:11 ttys3

@ttys3

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

Your workaround is for a different module.

MikeMcC399 avatar Nov 17 '23 04:11 MikeMcC399

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

https://github.com/petkaantonov/urlparser/blob/545dcd3ecf148ac9e27a8910db54f9a6f74f441b/src/urlparser.js#L401

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

MikeMcC399 avatar Nov 17 '23 04:11 MikeMcC399

I do not think it is actively maintained.

ttys3 avatar Nov 17 '23 05:11 ttys3

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

cedx avatar Nov 17 '23 08:11 cedx

@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

https://github.com/petkaantonov/urlparser/blob/545dcd3ecf148ac9e27a8910db54f9a6f74f441b/src/urlparser.js#L401 to change instead to:

var punycode = require("punycode/");

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

MikeMcC399 avatar Nov 20 '23 03:11 MikeMcC399