Build configuration
Configuring Chainguard Libraries for JavaScript on your workstation
For the complete documentation index, see llms.txt.
JavaScript and npm package consumption in a large organization is typically managed by a repository manager. Commonly used repository manager applications are JFrog Artifactory, Sonatype Nexus Repository, and others. The repository manager acts as a single point of access for developers and development tools to retrieve the required libraries.
If your organization uses the upstream fallback
feature of Chainguard Repository, you can configure your repository manager
with a single upstream pointed at https://libraries.cgr.dev/javascript/. This
is the recommended setup. The Chainguard Repository handles fallback and policy
enforcement; your repository manager handles local caching and access control.
Chainguard also retrieves packages from the public npm Registry on your
behalf when upstream fallback is enabled. This includes protections such as
malware detection and a cooldown period for newly published
packages.
At a high level, adopting the use of Chainguard Libraries consists of the following steps:
https://libraries.cgr.dev/javascript/
as the single upstream source for JavaScript package retrieval. This can be done
either:Adopting the use of a repository manager is the recommended approach to minimize complexity. If your organization does not use a repository manager, refer to the direct access documentation for build tools.
Chainguard recommends using the Chainguard Repository’s built-in upstream fallback rather than configuring a public registry fallback in your repo manager. Configuring your own fallback bypasses the protection that the Chainguard Repository provides.
However, if upstream fallback is not enabled or you prefer to manage your own fallback
ordering, you can configure https://libraries.cgr.dev/javascript/ as a remote
repository alongside your npm upstream, and combine them in a virtual or group
repository with Chainguard as the first priority. The per-tool instructions on
this page follow this pattern.
Cloudsmith supports npm registries for proxying and hosting. Refer to the npm registry documentation and the npm Upstream documentation for Cloudsmith for more information. Cloudsmith supports combining repositories by defining multiple upstream repositories.
Use the following steps to configure a repository with the Chainguard Libraries for JavaScript repository as an upstream.
Configure a javascript-all repository. This repository acts as a single access point for JavaScript packages and may also include private packages or additional upstream sources, depending on your configuration.
Configure an upstream proxy for the Chainguard Libraries for JavaScript repository:
https://libraries.cgr.dev/javascript/If you are manually managing fallback, you can add an additional upstream
proxy for the public npm registry with a lower priority than
javascript-chainguard.
Use this setup for initial testing with Chainguard Libraries for JavaScript. For
production usage, add the javascript-chainguard upstream proxy to your production
repository.
The following steps allow you to determine the URL and authentication details for accessing the repository:
example organization is
https://npm.cloudsmith.io/example/javascript-all/.example organization is
//npm.cloudsmith.io/example/javascript-all/:_authToken=YOUR-API-KEYUse the provided code snippets directly for your use with npm, or adjust as necessary for other JavaScript build and packaging tools. Find relevant details in the Build Configuration and specific packaging tool documentation.
Use the following steps to retrieve the necessary API key as an authentication token for the registry access:
JFrog Artifactory supports npm repositories for proxying and hosting, and virtual repositories to combine them. Refer to the npm registry documentation for Artifactory for more information.
Use the following steps to add Chainguard Libraries for JavaScript as a remote repository:
Configure a remote repository for the Chainguard Libraries for JavaScript repository:
javascript-chainguard.https://libraries.cgr.dev/javascript/.Create a virtual repository, or add the remote repository to an existing virtual repository used for npm packages. A virtual repository may also include private npm packages or additional upstream sources, depending on your configuration.
javascript-chainguard.If you are manually managing fallback, you can configure an additional npm remote repository with lower priority.
Use this setup for initial testing with Chainguard Libraries for JavaScript. For
production usage add the javascript-chainguard repository to your production
virtual repository.
Chainguard Libraries uses Cloudflare R2 storage, meaning tarball downloads from
libraries.cgr.dev return a 302 redirect to a different host. Without
additional configuration, Artifactory may cache the redirect response instead of
the actual tarball, causing npm integrity checksum failures at install time.
To prevent this:
javascript-chainguard
remote repository, within in the Advanced tab:javascript-chainguard repository and click Zap Caches, then re-run your
install..tgz artifacts from
the remote cache, rather than deleting all, before re-running the install.The following steps allow you to determine the URL and authentication details for accessing the repository:
https://exampleorg.jfrog.io/artifactory/javascript-all/ with exampleorg
replaced with the name of your organization.Use the URL of the virtual repository in the build configuration and build a first test project. In a working setup the chainguard remote repository contains all libraries retrieved from Chainguard.
Sonatype Nexus Repository allows for merging multiple remote repositories as a repository group. The below instructions are based on the Nexus documentation for npm.
For initial testing and adoption it is advised to create a separate proxy repository for the Chainguard Libraries for JavaScript repository, and include it in a repository group:
Configure a proxy repository for the Chainguard Libraries for JavaScript repository:
https://libraries.cgr.dev/javascript/.Create a repository group, or add to an existing repository group:
javascript-chainguard to the right to include it in the group. Position
javascript-chainguard at the top of the list using the arrow controls.Repository groups can include multiple repositories, such as hosted repositories for private packages or additional proxy repositories. In a typical configuration, the Chainguard repository is placed first to ensure packages are retrieved through Chainguard when available.
If you are manually managing fallback, you can configure an additional npm proxy repository and add it to the group after javascript-chainguard.
The following steps allow you to determine the URL and authentication details for accessing the repository:
https://repo.example.com/repository/javascript-all/
with repo.example.com replaced with the hostname of your repository manager.Use the URL of the repository group, such as
https://repo.example.com/repository/javascript-all/ in the build
configuration and build a
first test project. In a working setup the javascript-chainguard proxy
repository contains all libraries retrieved from Chainguard.
Last updated: 2025-06-05 09:00