Publishing a Package to Deno's Official Registry

Learn how to create a module on Deno's repository and get it published.

We'll cover the following

Open source is, at its core, made of people and companies that use free software and have the desire to give back. When we create a piece of code that we think is interesting enough, we most likely want to share it. This is not only a way of helping other people but also a way to improve your own code.

Open source and this culture of sharing is what made Deno, Node.js, and many other technologies we use a reality. Since this course is all about Deno, it wouldn’t make sense to finish it without going over this topic.

Deno has an official module registry that we’ve used before. This is a place where anyone with a GitHub account can share their own modules with the community, and it provides automation and caching mechanisms to keep different versions of modules.

What we’re going to do next is publish a module of our own to this same registry.

We’ll use a piece of software that, until now, we made available via the direct link to GitHub. This works, but it has neither clear versioning nor any type of cache, making it unusable if the code is deleted from GitHub.

Remember when we used an AuthRepository that lived inside a package we called jwt-auth? At the time, for practical reasons, we used a direct GitHub link, but from now on we’ll publish it in Deno’s module registry.

We’ll use the exact same code that’s hosted on GitHub but publish it with the name of deno_web_development_jwt_auth. We’re choosing this name to make it very clear that it’s part of this course’s journey. We also don’t want to grab meaningful names from the registry for packages developed for learning purposes.

Steps for creating a repository

Let’s go! Proceed as follows:

  1. Create a repository for the module you want to publish. As mentioned, we’ll be using the jwt-auth module we have used previously, but feel free to use any other module of your choice.

  2. Clone the recently created git repository by following GitHub’s instructions. Make sure to copy the module’s files to this repository folder, and run the following commands (these are the same as those presented in GitHub’s instructions):

Get hands-on with 1200+ tech skills courses.