But the current version (4.1.2) of the @forge/api package still uses the built-in punycode module, which entered the runtime deprecation stage in Node.js 21. This means that every time a function is invoked, the following error is logged:
[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
The reason for this warning is that @forge/api uses an old version of node-fetch. One of its dependencies imports the built-in punycode module instead of using the one published on npm (which has the same name and is not deprecated):
@forge/api@4.1.2
└─┬ node-fetch@2.7.0
└─┬ whatwg-url@5.0.0
└── tr46@0.0.3 <- This one uses `punycode`
The deprecation doesn’t affect the functionality of apps, but it produces a lot of unnecessary log lines.
The rollout of the runtime support is disappointing.
I have to rollback switching to Node 22 from our dev branch because of these two issues (punycode and @forge/cli). Note that all Forge documents appear to be encouraging node22 despite these issues.
Hi all, thank you for providing feedback. Firstly, I’d like to apologise about your experience, I have made a note of all of your points.
Just to give you all an update on some of the issues that you’ve noticed:
Regarding the use of v2 of node-fetch (which has a dependency on deprecated punycode) we have plans to remove this dependency all together from @forge/api in preference of global fetch, which is available from Node.js 18 onwards (ticket). This is on our team’s backlog for this quarter.
Regarding CLI support, the CLI should work with Node.js 22 out of the box, we will need to update a couple of things (that warning and the fact that the CLI has a dependency on node-fetch as well). I have created a ticket for this and have shared it with the relevant team.
I also want to point out that the CLI is independent of the Forge runtime, so you can use different Node.js versions between the two. At the same time, I understand that you probably want to be running the same version of Node.js locally so you can test your app locally running the same version under Forge tunnel.
Hi, please follow this ticket for updates regarding the removal of node-fetch from @forge/api.
In terms of adopting the Node.js 22 runtime, as far as I know this is a deprecation warning so should not affect the functionality of your app so you may use it. If you wish to stay on Node.js 20 runtime until we rollout an update for the @forge/api package, that’s totally valid as well.