laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
45.19k stars 4.92k forks source link

[CLI] DeprecationWarning: The `punycode` module is deprecated. #10992

Open Philipp91 opened 2 weeks ago

Philipp91 commented 2 weeks ago

Operating system

Linux

Joplin version

3.0.1

Desktop version info

No response

Current behaviour

$ joplin version

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

Copyright © 2016-2024 Laurent Cozic
joplin 3.0.1 (prod, linux)

Expected behaviour

No warning.

Logs

With --trace-deprecation:

(node:105403) [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:96:7)
at Module._load (node:internal/modules/cjs/loader:1063:17)
at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
at Module.require (node:internal/modules/cjs/loader:1297:12)
at require (node:internal/modules/helpers:123:16)
at Object.<anonymous> (/home/philipp/.nvm/versions/node/v22.3.0/lib/node_modules/joplin/node_modules/markdown-it/lib/index.js:14:20)
at Module._compile (node:internal/modules/cjs/loader:1460:14)

The solution should be to update to markdown-it v14 (https://github.com/markdown-it/markdown-it/commit/beed9aee2c1b44819afc25d485e86a6c699b6ef0).

pedr commented 1 week ago

We could upgrade markdown-it version, but there seem to be a lot of dependencies that still would cause the warning.

When I upgraded markdown-it I discovered that whatwg-url@"<9.0" also uses punycode, which is used by node-fetch@"<3.0.", which is an indirect and direct dependency by a lot of libraries like sqlite3, canvas, tesserac, turndown-attendant, to name a few. Try: npm why whatwg-url@"<9.0.0"

The warning is showing up for Node >=21, 22 becomes LTS at the end of the year.

Should we look into upgrading only the direct dependencies that use something that was using the native punycode or maybe find a way to hide the warning when running the joplin bin for app-cli? @laurent22

laurent22 commented 6 days ago

Is there any other way to disable this warning? I know there's an env variable that can be set - but whatever is being done, can it be done at the application level?

pedr commented 4 days ago

Is there any other way to disable this warning? I know there's an env variable that can be set - but whatever is being done, can it be done at the application level?

We would need to run the joplin build with something like NODE_OPTIONS=--no-deprecation node main.js, I tried some methods but I couldn't find a way yet.

Node has the process.noDeprecation but it is a read-only property https://nodejs.org/api/process.html#processnodeprecation

pedr commented 4 days ago

I think maybe we could add dotenv to app-cli project, I'm not sure if this is going to work, but I will try this strategy next.

pedr commented 4 days ago

https://askubuntu.com/questions/333133/how-to-set-app-icon-in-the-desktop-file-of-an-ubuntu-touch-application