Node22 migration guide
How to migrate your Optimizely Connect Platform (OCP) app to Node22 runtime.
This article provides steps to migrate an existing Optimizely Connect Platform (OCP) app to node22 runtime,
ensuring compatibility with the latest OCP features and performance improvements.
Prerequisites
An existing OCP app using node18 runtime. Check the runtime in the app.yml file.
Migrate OCP app to node22 runtime
node22 runtimeComplete the following steps to migrate your OCP app to node22 runtime:
Run the correct Node.js version
Ensure you are running the correct Node.js version when migrating the OCP app. The node22 engine uses Node.js version 22. See the following example:
node --version
v22.14.0(Required) Update application configuration
Modify the runtime setting in your app.yml file to specify the node22 runtime.
runtime: node22(Required) Upgrade required dependencies
- Upgrade libraries to required versions.
node22runtime requires2.xversions of@zaiusinc/app-sdkand@zaiusinc/node-sdklibraries.--ignore-enginesflag is needed to temporarily bypass engine checks during installation.yarn add --ignore-engines "@zaiusinc/[email protected]" "@zaiusinc/[email protected]" - Upgrade Node.js type definitions to a version compatible with Node.js 22. Ignore warnings about unmet peer dependencies during the installation.
yarn add --dev --ignore-engines "@types/node@^22.15.17"
(Required) Upgrade ESLint
-
Upgrade ESLint to v9. OCP
node22runtime uses ESLint v9. Because ESLint dependencies used bynode18OCP runtime are not compatible with Node.js version 22, it is required to update ESLint to v9. -
Remove existing ESLint-related dependencies from your
package.jsonfile. Ignore errors about modules not specified in thepackage.jsonfile. The new version of@zaiusinc/eslint-config-presetslibrary includes the necessary dependencies required by the default ESLint configuration used by OCP apps, simplifying the dependencies in yourpackage.jsonfile.yarn remove --ignore-engines @eslint/compat yarn remove --ignore-engines @stylistic/eslint-plugin yarn remove --ignore-engines @typescript-eslint/eslint-plugin yarn remove --ignore-engines @typescript-eslint/parser yarn remove --ignore-engines eslint yarn remove --ignore-engines eslint-plugin-import yarn remove --ignore-engines eslint-plugin-jsdoc yarn remove --ignore-engines eslint-plugin-prefer-arrow yarn remove --ignore-engines eslint-plugin-react yarn remove --ignore-engines tslint yarn remove --ignore-engines @typescript-eslint/eslint-plugin-tslint yarn remove --ignore-engines @zaiusinc/tslint-presets -
Upgrade other ESLint-related dependencies in your app to ESLint v9 and the Node.js v22 compatible version.
-
Upgrade
eslint-config-presetslibrary.--ignore-enginesflag is needed to temporarily bypass engine checks during installation.yarn add --ignore-engines --dev "@zaiusinc/eslint-config-presets@^3.0.0" "eslint-plugin-jest@^28.11.0" -
Use the following default ESLint configuration file used by OCP apps (
eslint.config.mjs). ESLint v9 introduced a new configuration format that useseslint.config.jsoreslint.config.mjsfiles instead of the older.eslintrc.jsor similar files.import jest from 'eslint-plugin-jest'; import node from '@zaiusinc/eslint-config-presets/node.mjs'; export default [ ...node, { files: ['**/*.test.ts'], plugins: { jest, }, rules: { '@typescript-eslint/unbound-method': 'off', 'jest/unbound-method': 'error', }, }]; -
Create
eslint.config.mjsfile in the root folder of your app with the content from the ESLint configuration file. If you did not customize your ESLint configuration, you can start using the new file. If you customized, you must migrate your old configuration to the new format. You can do this individually or use the ESLint migration script. See ESLint v9 migration guide.See the default ESLint configuration file used by OCP apps in the old format below. If the content of your existing
.eslintrc.jsfile matches the content, you do not have any customizations.module.exports = { extends: '@zaiusinc/eslint-config-presets/node', overrides: [ { files: ['**/*.test.ts'], plugins: ['jest'], rules: { // you should turn the original rule off *only* for test files '@typescript-eslint/unbound-method': 'off', 'jest/unbound-method': 'error', }, }, ], rules: { }, } -
Run linter and automatically fix issues:
yarn lint --fixIf you still face linting issues, fix them individually by changing the code or modifying rules in
eslint.config.mjsto match your needs. -
Remove old ESLint configuration files (
.eslintrc.js):rm .eslintrc.js
(Required) Check third-party dependencies and compatibilities
- Remove
yarn.lockandnode_modulesand install dependencies again to rebuild dependencies:If the command succeeds, it means your dependencies are compatible with Node.js 22. If it fails, you must upgrade or replace incompatible third-party dependencies. Do this individually (rm yarn.lock rm -rf node_modules yarn installyarn add --ignore-engines [--dev] "<dependency>@<compatible_version>"or by conducting manual edits ofpackage.jsonfile), untilyarn installcommand succeeds. - Run
ocp app validateto upgrade both@zaiusinc/app-sdkand@zaiusinc/node-sdkto the versions currently used by OCP. This command will also build and validate your app.ocp app validate - Approve changes if the command asks you to upgrade
@zaiusinc/app-sdkand@zaiusinc/node-sdkto the latest versions.
Typical migration errors
Implement the following solutions to typical errors you might encounter related to ESLint, TypeScript, or Jest while migrating your OCP app to node22 runtime:
- Compilation errors caused by third-party dependency upgrade – Fix the compilation errors individually.
- Third-party dependencies conflicting with
@zaiusinc/app-sdkor@zaiusinc/node-sdksub-dependencies – Upgrade the dependency to a compatible version. - App code incompatible with
@types/[email protected]– Fix the code to be compatible with the new type definitions.
Consider the following optional steps to upgrade related dependencies to common compatible versions. Skip to Clean up and validate if your app is functional after the initial migration steps.
Upgrade TypeScript version
- Upgrade your app's TypeScript version to match the runtime version. OCP
node22runtime uses TypeScript version5.8.3. Ignore warnings about unmet peer dependencies during the installation.yarn add --dev "typescript@^5.8.3" - Run
ocp app validatecommand to verify the changes:ocp app validate - Fix any TypeScript-related issues individually if the command reports them.
Upgrade other dev-dependencies used by OCP
- Upgrade other dev-dependencies to versions compatible with Node.js 22 and OCP
node22runtime. To improve performance, OCP migrated from@atao60/fse-clitocpy-clipackage. Addcpy-clipackage to your dev-dependencies:yarn add --dev "cpy-cli@^6.0.0" - Replace
buildscript in yourpackage.jsonfile to usecopyfilesinstead of@atao60/fse-cli. The updatedbuildscript must look like the following example:"build": "yarn && npx rimraf remove dist && npx tsc && cpy app.yml dist && cpy --up 1 \"src/**/*.{yml,yaml}\" dist", - Remove unnecessary dependencies. Skip this step if you are still using these packages in your app, and ignore warnings about unmet peer dependencies during the installation.
yarn remove --ignore-engines @atao60/fse-cli chalk - Upgrade other dev-dependencies to compatible versions. Ignore warnings about unmet peer dependencies during the installation.
yarn add --dev "dotenv@^16.5.0" "rimraf@^6.0.1" "@types/node-fetch@^2.6.12" - Run
ocp app validatecommand to verify the changes:This command should complete successfully. If an error occurs, it is likely due to a version conflict with a third-party dependency. Resolve these conflicts individually.ocp app validate
Upgrade Jest
- Run the following command to upgrade Jest and any related packages to version
29.7.0:yarn add --dev "@types/jest@^29.5.14" "jest@^29.7.0" - Run
ocp app validatecommand to verify the changes:ocp app validate - Fix the issues individually if the compilation or tests fail.
Clean up and validate
- Rebuild dependencies again:
rm yarn.lock rm -rf node_modules yarn install - Run a final validation check on your app:
ocp app validate - Deploy a new
-devor-betaversion of your app to OCP and test thoroughly to ensure everything works successfully.
Updated about 1 hour ago