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

punycode is deprecated, remove dependency #94

Closed
stheine opened this issue Oct 26, 2023 · 14 comments · May be fixed by #95
Closed

punycode is deprecated, remove dependency #94

stheine opened this issue Oct 26, 2023 · 14 comments · May be fixed by #95

Comments

@stheine
Copy link

stheine commented Oct 26, 2023

Recently I get a deprecation warning on application startup.

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

uri-js brings this dependency, so you should look at getting rid of it, please.

@MikeMcC399

This comment was marked as outdated.

@MikeMcC399
Copy link

@stheine

Did you get the deprecation warning when you were running uri-js or when you were installing it?

If it was an installation warning, were you using Yarn Classic v1 and Node.js 21.x to install uri-js?

@wolfgangwalther
Copy link

wolfgangwalther commented Nov 1, 2023

Did you get the deprecation warning when you were running uri-js or when you were installing it?

I get a lot of those warnings when running code (jest tests via node).

Seems like the following line will always import the deprecated core module:

import punycode from "punycode";

Also see this hint in the punycode repo:

⚠️ Note that userland modules don't hide core modules. For example, require('punycode') still imports the deprecated core module even if you executed npm install punycode. Use require('punycode/') to import userland modules rather than core modules.

Edit: However, just tried import punycode from "punycode/"; - this fails with the following when trying to build:

src/uri.ts(39,22): error TS2307: Cannot find module 'punycode/'.

@wolfgangwalther
Copy link

Ah, according to mathiasbynens/punycode.js#122, the same package is also published as punycode.js on npm to avoid the name conflict.

@MikeMcC399
Copy link

@wolfgangwalther

I'm not certain that the warnings are coming from uri-js.

With uri-js-test.js

const URI = require("uri-js");

console.log(URI.parse("uri://user:pass@löwenbräu.com:123/one/two.three?q1=a1&q2=a2#body"));

I see no warning

$ node -v
v21.1.0
$ node uri-js-test.js
{
  scheme: 'uri',
  userinfo: 'user:pass',
  host: 'l%C3%B6wenbr%C3%A4u.com',
  port: 123,
  path: '/one/two.three',
  query: 'q1=a1&q2=a2',
  fragment: 'body',
  reference: 'uri'
}

Do you have any logs showing that the warning is coming from uri-js?

@wolfgangwalther
Copy link

Right. I was mislead by uri-js being the only dependency I have that has punycode listed as a dependency. But looking at this with NODE_OPTIONS=--trace-deprecations in fact, this seems to originate somewhere else.

@stheine
Copy link
Author

stheine commented Nov 2, 2023

ok, thanks, I understand now, that I submitted this issue into the wrong project, as uri-js already uses the userland package. using the --trace-deprecation I found the correct package to ask for an update in my case.
thanks and ok to close this issue.

@MikeMcC399
Copy link

@stheine

It's good you were able to confirm!

You should be able to close the issue yourself.

The Close button is normally shown down below ⬇️ if you are the Author of the issue.

@stheine stheine closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
@domdomegg
Copy link

I'm not sure uri-js is using the userland package. It requires punycode instead of punycode/ (or punycode.js). I think this needs fixing in uri-js.

@domdomegg
Copy link

I've opened a PR to fix this here: #95

@andreinwald
Copy link

#97 - replacement for this library

@ildella
Copy link

ildella commented May 10, 2024

Maybe the problem is the way it is required, as according to https://github.com/mathiasbynens/punycode.js:

⚠️ Note that userland modules don't hide core modules. For example, require('punycode') still imports the deprecated core module even if you executed npm install punycode. Use require('punycode/') to import userland modules rather than core modules.

@MikeMcC399
Copy link

@ildella

You may be in the wrong repository with your problem. Could you set

export NODE_OPTIONS='--trace-deprecation'

then execute the instructions where you saw the warning and then post the instructions and the output here?

@ildella
Copy link

ildella commented May 13, 2024

The quote is from the punycode.js README, not some output I get on my machine.

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

Successfully merging a pull request may close this issue.

7 participants
@ildella @domdomegg @andreinwald @wolfgangwalther @stheine @MikeMcC399 and others