will be shutting down on April 15th. Learn more

How to sell an npm package

It is very easy to start selling an npm package using basetools. However, there are some prerequisites to start selling: You have to have a private Github repository inside an organization and you have to publish your package using the Github registry. But we will cover all of this within this guide.

Set up the repository

For this guide, we will create a brand new repository on Github and start from there. If you have already created a repository, you can just skip this step.

For our example, we are creating a new private repository within our organization basetools-io.

Create a new repository on GitHub

In this case, our new repository is called basetools-npm-showcase. So let's get started on your machine:

mkdir basetools-npm-showcase
echo "# basetools-npm-showcase" >>
echo 'module.exports = () => console.log("hello world")' >> index.js
git init
git add index.js
git commit -m "first commit"
git branch -M main
git remote add origin
git push -u origin main

We have now created a private repository.

Setup the package.json

Next, we need to initialize the package.json, so that our repository can be treated as an npm package. We can easily do this by calling npm init. Important: Our package name has to contain our organization name. So instead of basetools-npm-showcase we have to call our package @basetools-io/basetools-npm-showcase. Make sure to commit the package.json to your repository.

Publish the package to your Github registry

In order to always publish this package to the Github registry, you have to configure the npm registry in your package.json:

"publishConfig": {

You also have to log in with your Github account. To do that, first generate a personal access token here: Make sure to activate the write:packages permission. Copy the generated token. Now, back in the terminal type in

npm login --registry=

If this was successful, you can finally publish your package:

npm publish

Adding the product on basetools

Once you have completed the steps above, you can create an account on basetools if you haven't done so yet. After registration click that you want to add a new product.

Add the npm package as product to basetools

And just like that, you can start selling! basetools automatically creates a checkout page for you. You can link to this page from your website, for example. After a successful payment, your customer will be automatically invited to your repository as a collaborator. This will grant him access to the repository and the packages:

Confirmation of a sale of your npm package

How to install the package as your customer

Once your customer has bought access to your repository, he also has to log in to npm with the Github account that was used when buying your product:

npm login --registry= --scope=@OWNER

Where @OWNER is the name of your repositories account, in our example @basetools-io. When this was successful, the package can be installed like any other npm package:

npm install @basetools-io/basetools-npm-showcase

Basetools in the meantime will create a correct invoice, handling VAT and billing and send you a payout after a few days.

So, what are you waiting for? We can’t wait to find out what you are going to sell! Sign up now