How it works

Learn how to setup your own private npm registry and publish your first package

With privatepkgs, you are getting your own private version of npm. It allows you to distribute access via licenses, so you’re always in control of who’s able to access your packages.

The following 4 steps will guide you through the process of setting up your own private npm registry and publishing your first package.

1. Create your package

After you created your team with your namespace, you’re able to create a new package through the dashboard.

Create Package

npm install @namespace/package

Once created, your package is available under @namespace/package on the privatepkgs registry.

2. Publish your package

Update the namespace and the package name in your package.json so it matches everything on privatepkgs and run the following commands to setup your local npm CLI:

npm config set "@namespace:registry" https://registry.npm.privatepkgs.com/npm config set "//registry.npm.privatepkgs.com/:_authToken" TOKEN

This instructs npm to use the registry of privatepkgs instead of the default one from npm.

Now you’re able to publish your package by running

npm publish

3. Create your first license

After you published your package, you’re able to view its contents and information through the dashboard. Head over to the License tab and create your first license.

Create Package

You are able to specify different license types, like unlimited, or date- or version-based. You can also specify which packages the user is able to access with this license.

Everything you specify through the UI can be also done via API to automate the process.

4. Let customers install your package

Customers with a license – like with the one you just created – are now able to install your package. All they need to do, is adding a .npmrc file in their project folder, with the following contents:

@namespace:registry=https://registry.npm.privatepkgs.com///registry.npm.privatepkgs.com/:_authToken=LICENSE-KEY

After that, running the following command will install the package from the registry

npm install @namespace/package

Bonus: Using your own domain

Instead of providing your customers with the domain of privatepkgs, you can also setup your own domain. Head over to the dashboard and setup your own custom domain.

Customers can setup their .npmrc file like this:

@namespace:registry=https://npm.acme.com///npm.acme.com/:_authToken=LICENSE-KEY