Node.js 22 compatibility

Forge runtime support for Node.js 22 was announced on 11 December and is recommended according to the documentation.

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.

12 Likes

I saw that as well and reverted back to v20.

Also the CLI doesn’t seem to support Node 22 either, only 18 and 20 see https://developer.atlassian.com/platform/forge/getting-started/#before-you-begin

5 Likes

Also discussed here: Forge CLI does not support latest Node.js LTS version - #5 by SimonCordes

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.

2 Likes