Dev GuideAPI Reference
Dev GuideUser GuidesGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Package manager migration guide

A guide to migrate your Optimizely Connect Plaform (OCP) app from Yarn 1 to other package managers.

Follow this guide to migrate your Optimizely Connect Plaform (OCP) app from Yarn 1 to other packager managers, such as npm, pnpm, Bun, or Yarn Berry v3+.

Prerequisites

📘

Note

Package manager migration is only supported for apps on Node.js 22+ runtime. Apps using older runtines should continue using Yarn 1.

Supported package managers

OCP CLI v2 supports Yarn, including Yarn Berry v3+, npm, pnpm, and Bun. The build system automatically detects your package manager from your project configuration, including the lock files, the packageManager field in package.json, and more.

Migrate to the package managers

Implement the following steps to migrate to other package managers:

(Optional) Remove install scripts from package.json

OCP CLI v2 automatically uses the correct package manager for your app, eliminating the need for separate install scripts in package.json. You can remove redundant install scripts, though keeping them does not cause conflicts.

The following displays an example before removing install scripts:

{
  "scripts": {
    "build": "yarn && ...",
    "validate": "yarn build && ..."
  }
}

The following displays an example if you are still using Yarn as a package manager:

{
  "scripts": {
    "build": "...",
    "validate": "yarn build && ..."
  }
}
📘

Note

OCP CLI's default app templates intentionally omit package manager-specific shorthand build scripts. This design choice prevents confusion and simplifies switching package managers, as scripts like validate already encompass all necessary build, test, and lint steps. You can convert these to shorthand commands if preferred.

Remove grpc-boom from resolutions

The grpc-boom resolution is no longer necessary for applications running on Node.js 22 and newer. Remove it from your package.json.

🚧

Important

This change applies only to apps using Node.js 22+. Applications on older runtimes still require this resolution.

The following displays an example before removing grpc-boom from resolutions:

{
  "resolutions": {
    "grpc-boom": "^3.0.11"
  }
}

The following displays an example after removing it:

{
  // Remove the resolutions block entirely if grpc-boom was the only entry
}

Update validation script

Replace the manual validation script path with the ocp-app-sdk validate command.

📘

Note

The ocp-app-sdk CLI is only available in @zaiusinc/[email protected] or newer versions, which require Node.js 22+ runtime.

The following displays an example before replacing the manual validation script:

{
  "scripts": {
    "validate": "yarn build && yarn lint && yarn test && cross-env LOG_LEVEL=never node node_modules/@zaiusinc/app-sdk/dist/app/validation/runValidation.js"
  }
}

The following displays an example after replacing it:

{
  "scripts": {
    "validate": "yarn build && yarn lint && yarn test && cross-env LOG_LEVEL=NEVER ocp-app-sdk validate"
  }
}

Switch to your preferred package manager

To switch from Yarn to another package manager, complete the following:

  1. Delete the existing yarn.lock file.
  2. Initialize your new package manager, which creates the following lock file:
  3. # For npm
    npm install
    
    # For pnpm
    pnpm install
    
    # For bun
    bun install
    
    # For Yarn Berry
    yarn set version berry
    yarn install
  4. (Optional) Explicitly define your preferred package manager by adding the packageManager field to your package.json file.

Update scripts in package.json

Update your package.json scripts to use your preferred package manager's commands:

Yarn 1npmpnpmBun
yarnnpm installpnpm installbun install
yarn buildnpm run buildpnpm buildbun run build
yarn testnpm testpnpm testbun test
yarn lintnpm run lintpnpm lintbun run lint

Example for npm

{
  "scripts": {
    "validate": "npm run build && npm run lint && npm test && cross-env LOG_LEVEL=NEVER ocp-app-sdk validate"
  }
}

Example for pnpm

{
  "scripts": {
    "validate": "pnpm build && pnpm lint && pnpm test && cross-env LOG_LEVEL=NEVER ocp-app-sdk validate"
  }
}
📘

Note

If migrating to Yarn Berry (v3+), you can continue using existing yarn commands as they remain compatible.

Validate your app

Run the following validation command to ensure full functionality. If it runs successfully, your app is ready to use the new package manager.

ocp app validate

Quickstart to migration

  1. Confirm you are running OCP CLI v2. Your ocp --version should display v2.x.x.
  2. Ensure your application is configured for Node.js 22 or a newer runtime.
  3. Ensure that all team members and CI/CD pipelines are using OCP CLI v2.
  4. (Optional) Remove redundant install scripts from your package.json file.
  5. Delete the grpc-boom entry from your resolutions block in package.json.
  6. Modify your validation script to use ocp-app-sdk validate.
  7. Migrate to your preferred package manager:
    1. Delete your existing yarn.lock or equivalent file.
    2. Run the install command for your preferred package manager (for example, npm install, pnpm install, yarn install).
  8. Update any scripts in package.json to reflect the commands of your newly adopted package manager.
  9. Run ocp app validate to confirm all changes are working correctly.