Storybook CLI: Develop, document, and test UI components in isolation
—
Upgrade Storybook packages to newer versions with compatibility checks and automigrations. The upgrade system handles dependency management, version conflicts, and automatically applies necessary migrations to keep your Storybook installation up-to-date and compatible.
Upgrades Storybook packages to the latest compatible version with automated migration support.
storybook upgrade [options]
Options:
--package-manager <npm|pnpm|yarn1|yarn2|bun> Force package manager for installing dependencies
-y, --yes Skip prompting the user
-f, --force Force the upgrade, skipping autoblockers
-n, --dry-run Only check for upgrades, do not install
-s, --skip-check Skip postinstall version and automigration checks
-c, --config-dir <dir-name...> Directory(ies) where to load Storybook configurations fromUsage Examples:
# Basic upgrade to latest version
npx storybook upgrade
# Upgrade with specific package manager
npx storybook upgrade --package-manager yarn1
# Check what would be upgraded without installing
npx storybook upgrade --dry-run
# Force upgrade, bypassing compatibility checks
npx storybook upgrade --force
# Skip prompts and use defaults
npx storybook upgrade --yes
# Upgrade and skip postinstall checks
npx storybook upgrade --skip-check
# Upgrade multiple Storybook configurations
npx storybook upgrade --config-dir .storybook --config-dir packages/*/\.storybookThe upgrade system detects and manages various Storybook package versions:
@storybook/core-*, storybook@storybook/react, @storybook/vue3, etc.@storybook/addon-*@storybook/builder-*@storybook/cliAutomated checks prevent problematic upgrades:
Handle monorepos and multiple Storybook instances:
# Upgrade all Storybook configurations in a monorepo
npx storybook upgrade --config-dir packages/app/.storybook --config-dir packages/components/.storybook
# Automatically discover Storybook configurations
npx storybook upgrade # Discovers .storybook directories automaticallyThe upgrade process handles:
Post-upgrade validation includes:
import { upgrade } from "@storybook/cli";
/**
* Upgrade Storybook packages programmatically
* @param options - Upgrade configuration
*/
function upgrade(options: UpgradeOptions): Promise<void>;
interface UpgradeOptions {
packageManager?: PackageManagerName;
yes?: boolean;
force?: boolean;
dryRun?: boolean;
skipCheck?: boolean;
configDir?: string[];
}
/**
* Extract Storybook version from npm output line
* @param line - npm output line
* @returns Package info or null
*/
function getStorybookVersion(line: string): Package | null;
/**
* Check version consistency across Storybook packages
* @param packages - List of package information
* @returns Consistency check results
*/
function checkVersionConsistency(packages: Package[]): ConsistencyResult;
interface Package {
package: string;
version: string;
}
type PackageManagerName = "npm" | "pnpm" | "yarn1" | "yarn2" | "bun";Programmatic Examples:
import { upgrade, getStorybookVersion } from "@storybook/cli";
// Upgrade programmatically
await upgrade({
packageManager: "npm",
yes: true,
dryRun: false
});
// Parse version from npm output
const packageInfo = getStorybookVersion("@storybook/react@7.6.17");
// Returns: { package: "@storybook/react", version: "7.6.17" }The upgrade system maintains compatibility with:
Different approaches for different scenarios:
Robust error handling for common upgrade issues:
Install with Tessl CLI
npx tessl i tessl/npm-storybook--cli