Install your first package
Install a package through Depot without creating an organization token. This walkthrough uses npm and the built-in npmjs cache. Other clients follow the same flow in the ecosystem guides.
Before you begin
You need a Depot account, membership in a Depot organization, the Depot CLI, and npm. Reader access is sufficient to install packages.
Install through Depot
-
Sign in to Depot:
depot login -
Open your organization's Packages, select Cache repositories, and open npmjs. Copy the organization ID from the repository endpoint on Setup.
-
Load your personal credential into the current shell:
export DEPOT_TOKEN="$(depot login token)" npm config set registry https://packages.depot.dev/<org-id>/npm/npmjs/ --location=project npm config set '//packages.depot.dev/<org-id>/npm/npmjs/:_authToken' '${DEPOT_TOKEN}' --location=userReplace
<org-id>with the copied organization ID. The project configuration contains the registry URL. The user configuration contains an environment-variable reference, so the token stays in your shell. -
Install a dependency:
npm install lodashnpm uses the environment credential to install
lodash, and Depot caches the upstream download. You can find the package in thenpmjsrepository in Packages.
Keep DEPOT_TOKEN set while using npm. Refresh it when your login credential changes, and run unset DEPOT_TOKEN when finished. In CI, preserve the injected credential and use the same registry and user authentication configuration.
Publish a private package
Publishing requires a Private repository or a Virtual repository with publishing enabled. Ask an owner or administrator to create a Private npm repository named internal in Packages.
-
In a package project with a valid
nameandversioninpackage.json, configure the publish destination:npm config set '//packages.depot.dev/<org-id>/npm/internal/:_authToken' '${DEPOT_TOKEN}' --location=user npm pkg set publishConfig.registry=https://packages.depot.dev/<org-id>/npm/internal/The package must not have
"private": true. Choose a package name and version your team hasn't published. -
Publish the package:
npm publish -
Open
internalin Packages and confirm that the version appears.
The Private repository contains your packages. To install those packages alongside npm dependencies through one URL, create a Virtual repository.