DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Use Chromatic with a Private npm Package in CI

Authenticate CI to the registry that hosts your private dependency, install the project, and run Chromatic with its own project token.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Authenticate your CI job to the registry that hosts the private package, install your project dependencies, and then run Chromatic. These are two separate credentials: the package manager needs registry access to install the dependency, while Chromatic needs its own project token to publish the build.

How the two credentials fit together

Chromatic does not replace the credentials your package manager needs to fetch a private dependency. The registry token authorizes package installation; the Chromatic project token authorizes a Chromatic build. Keep them as separate CI secrets and expose each only to the step that needs it. Chromatic documents the project token as CHROMATIC_PROJECT_TOKEN, which its CLI recognizes automatically (Chromatic CLI documentation).

As an Amazon Associate I earn from qualifying purchases.

The order matters: install dependencies before running Chromatic so the Storybook project can resolve the private package during its build. Chromatic’s documented CI flow installs project dependencies before the Chromatic build (Chromatic CI documentation).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure private-package access for your registry

npmjs.org

For a private package hosted on npmjs.org, add this project-level .npmrc entry:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

Commit the file with the literal ${NPM_TOKEN} reference, not a live credential. Store the actual token as a protected CI secret named NPM_TOKEN, so npm can substitute it at runtime. npm recommends a project-specific .npmrc with a token variable for CI authentication (npm: Using private packages in a CI/CD workflow).

For a job that only installs packages and runs tests, use a granular read-only token where supported. Its owner or organization must also be authorized to read the package.

GitHub Packages

GitHub Packages uses a different setup: map the package’s scope to https://npm.pkg.github.com and use a credential eligible for that package. GitHub documents GITHUB_TOKEN for packages associated with the workflow repository when access is granted. For certain packages in other private repositories, it documents a personal access token (classic) with read:packages. Package-level Actions access and repository permissions can affect access, so use the instructions that match the package and organization (GitHub: Working with the npm registry).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Other registries

Do not assume the npmjs.org .npmrc line works for every registry. Check the registry endpoint, any package-scope mapping, the credential type it accepts, and whether the CI identity is granted read access.

Run the install before Chromatic

Adapt the sequence below to your CI provider and package manager. The YAML is illustrative rather than a drop-in workflow: secret syntax, Node setup, and install commands vary by provider and project.

# Illustrative CI sequence; adapt to your provider and package manager.
- checkout repository
- configure Node and the selected package manager
- install dependencies using the lockfile-preserving CI command
  environment:
    NPM_TOKEN: <protected CI secret for registry read access>
- run Chromatic
  environment:
    CHROMATIC_PROJECT_TOKEN: <protected Chromatic project secret>

For npm projects, use the CI install command appropriate to the lockfile—for example, npm ci when the project uses package-lock.json. The key is that registry credentials are present during installation, and the Chromatic token is present when the Chromatic command runs. Avoid printing secrets in logs or placing their literal values in the repository.

Configure and run Chromatic

Chromatic’s quickstart uses the chromatic package, a project token, and a command that builds the Storybook. Its default Storybook build script is build-storybook; projects with a different build setup can configure build-script-name or build-command (Chromatic configuration reference).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

One typical npm-based arrangement is to install the CLI as a project development dependency, then run it after the private package and the rest of the project dependencies have been installed:

npm install --save-dev chromatic
npx chromatic --project-token="$CHROMATIC_PROJECT_TOKEN"

In CI, set CHROMATIC_PROJECT_TOKEN from your secret store rather than typing a real token into the command or committing it. You can also use the supported CI action instead of invoking the CLI directly; either way, configure the token securely and point Chromatic at the intended Storybook build.

Monorepos

Run the install and Chromatic command in the correct workspace or subproject context so its dependencies and Storybook configuration are available. Chromatic’s custom CI guidance says each subproject needs its own project token (Chromatic: Automate Chromatic with your custom CI provider).

Troubleshoot installation and build failures

  • Install reports authorization failure or package not found: confirm the secret exists in the install step, the CI identity is permitted to read the package, and the configured registry and scope match the package host. Private package visibility and access rules are controlled by the registry owner or organization.
  • GitHub Packages install fails: check that the scope routes to https://npm.pkg.github.com, the credential is eligible for that package, and repository or package-level workflow access is granted.
  • Install succeeds but Storybook cannot resolve the package: check workspace configuration, whether the package is declared as a dependency available to the Storybook project, and whether CI ran from the intended directory. There is no universal Chromatic-specific workaround for project dependency or workspace misconfiguration.
  • Chromatic rejects the build token: verify that the Chromatic project token—not the registry token—is supplied as CHROMATIC_PROJECT_TOKEN for the Chromatic step, and that it belongs to the intended Chromatic project.
  • Chromatic builds the wrong Storybook or cannot find the build command: run from the intended subproject and configure the correct build script or command with Chromatic’s supported settings.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your workflow also needs website screenshots, ScreenshotNeo is a separate screenshot API and MCP server—not a replacement for registry authentication or Chromatic. A single GET request captures a URL as an image or PDF:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation. It accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides screenshot and PDF tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Best Value
Sale
Game Programming Patterns
  • Brand New in box. The product ships with all relevant accessories

Frequently Asked Questions

Does Chromatic need the private registry token?

No. The package manager needs registry credentials to install the dependency; Chromatic needs its separate project token to run a build.

Can I use one token for npm and Chromatic?

No. They authorize different services and should be stored and supplied separately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.