Upgrade to Node.js 22
Recipe ID
org.openrewrite.node.migrate.upgrade-node-22Artifact@openrewrite/recipes-nodejsMigrate deprecated APIs for Node.js 22 compatibility. Addresses Node 22 runtime deprecations and deprecations from earlier versions.
Composite recipeProprietary
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.node.migrate.upgrade-node-22If the recipe isn’t available locally, install it with:
mod config recipes npm install @openrewrite/recipes-nodejsDefinition
This recipe runs the following recipes in order.
- Increase Node.js engine version
org.openrewrite.node.migrate.increase-node-engine-version - Increase Node.js version in GitHub Actions
org.openrewrite.node.migrate.increase-node-engine-version-in-github-actions - Replace deprecated
util.types.isWebAssemblyCompiledModule()org.openrewrite.node.migrate.util.replace-is-webassembly-compiled-module - Find deprecated
punycodemodule usageorg.openrewrite.node.migrate.find-punycode-usage - Find deprecated
crypto.createCipher()andcrypto.createDecipher()usageorg.openrewrite.node.migrate.crypto.find-create-cipher - Replace deprecated
util.isX()methods with native JavaScriptorg.openrewrite.node.migrate.util.use-native-type-checking-methods - Replace deprecated
util._extend()withObject.assign()org.openrewrite.node.migrate.util.replace-util-extend - Replace deprecated
new crypto.Hash()andnew crypto.Hmac()with factory methodsorg.openrewrite.node.migrate.crypto.replace-hash-constructor - Coerce
process.exit()andprocess.exitCodeto integerorg.openrewrite.node.migrate.process.coerce-process-exit-code - Replace deprecated
Buffer.slice()withBuffer.subarray()org.openrewrite.node.migrate.buffer.replace-deprecated-slice - Remove usage of deprecated
process.features.tls_*propertiesorg.openrewrite.node.migrate.process.remove-usage-of-features-tls-underscore_constants - Remove unnecessary
util.promisify()on Promise-returning functionsorg.openrewrite.node.migrate.util.remove-promisify-on-promise