Publish your first package
This quickstart shows you how to create a Private npm repository, publish a package to it, and install that package in another project. For other package managers, see the package manager guides.
Before you begin
You need a Depot account, the Depot CLI, and npm. You also need owner or administrator access to a Depot organization to create a repository.
Create a Private repository
- Open your organization's Packages and select Create repository.
- Under Format, select npm. Under Kind, select Private.
- Enter
internalas the name, then select Create repository. - Open Setup and copy the organization ID from the repository endpoint.
Configure npm
-
Sign in to Depot:
depot login -
Route a package scope to the repository:
depot packages configure npm --org <org-id> --repository internal --scope @acmeReplace
<org-id>with the copied organization ID and@acmewith a scope for your packages. npm sends packages in that scope tointernaland continues to get other packages from the npm registry. The command saves the registry and your token in your user~/.npmrc.
Publish a package
-
Create a package in the
@acmescope:mkdir hello && cd hello npm init -y --scope=@acme -
Publish the package:
npm publish -
Open
internalin Packages and confirm that@acme/helloversion1.0.0appears.
Install the package
In another project, install the package:
npm install @acme/hellonpm downloads @acme/hello from internal.
Next steps
- Rerun
depot packages configurewhen your login token changes. - To install private packages and npm dependencies through one endpoint, combine private and upstream packages.
- To publish from CI, see authentication and CI and trusted publishing.