urlparser
urlparser copied to clipboard
Module `punycode` is deprecated since Node.js 21
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.
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
Do you have any logs which show that the npm module tr46 is used by fast-url-parser from this repo?
@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.
@MikeMcC399 I came to here because I am using facebook docusaurus.
and @docusaurus/core depends on -> serve-handler which depends on fast-url-parser
@MikeMcC399 I have updated the content and removed the non-related words
@ttys3
I have updated the content and removed the non-related words
Your workaround is for a different module.
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
I do not think it is actively maintained.
Why not simply use the url core module?
It supports Puny code thanks to the url.domainToASCII() function.
@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.