So you’ve come to a point in your developer where you seem to be repeating and/or copy~pasting the same piece of code across multiple projects. It could be some utility functions that are really helpful for the way you like to do things in code or it could a set of typescript types, you wish your frontend and backend code to share — whatever the case you’ll probably want to create your own npm package.

If you’ve landed here by chance, you might ask, “Why not use npmjs.com?” If you don’t mind your package to be public, sure, by all means, however, private packages on there will cost you money, not a lot, but some, which is not the case with Github package registry.

Create the package

For this example, we’ll use  https://tsdx.io/ to scaffold our package, quite simply because it takes care of all the config that is usually needed when you want to setup a typescript project from scratch:

npx tsdx create mylib

You’ll be given a couple of options to choose from, but those will not affect how you can publish the package later. Once the installation is complete, you’ll need to:

cd mylib

#npm #typescript #github

Private Npm Packages in Github Package Registry
1.35 GEEK