Create a free private npm registry with Bytesafe

Daniel Parmenvik
3 min readMay 8, 2020

It’s not always that you want to make your JavaScript code publicly available using the public registry npmjs.org. Using a private registry ensures that your JavaScript packages are just that — private.

Other scenarios to use a private registry are when you want to make sure you have the right level of control over your dependencies or increase security. Many npm security lists mention the importance of using an npm proxy to visualize dependencies, cache packages and to improve security, which is something I will not cover in this post.

This post describes how you can setup a free private npm registry using the service Bytesafe.

Disclaimer: I am one of the founders behind Bytesafe that offers free, secure and highly available private npm registries.

How to get started

Whenever you are onboarding on a new service or API you want that developer experience to be really good. For me this means that the service should be easy to understand and fast to get started.

Setting up something like Verdaccio for private registries is one alternative, but still means you need to setup your own infrastructure or run a container using Docker/Kubernetes. If you want to focus on your code and packages and want a private registry right now without any hassle then you should follow the steps below.

  1. Create account. Go to the Bytesafe Signup Page and select the account name that you would like to use. Now you can access your account through the web console and see registries, just use go to https://< workspace>.bytesafe.dev
  2. Sign-in. Use your Google or GitHub login or sign in using mail and password. Congratulations! You now have access to your private registry called “default”. It’s ready to be used.
    From start, the default registry is configured to use npmjs.org as an upstream to pull public packages, but this can be changed. You also have the option to rename or create more registries.
  3. Configure the npm client. Use the npm client with your new private registry.

a. First make sure you configure npm to use your newly created registry. This way you can skip using — registry when logging in or installing with npm

$ npm config set registry 'https://example.bytesafe.dev/r/default/'

b. Login to your registry using your Bytesafe registry credentials that you see in the Bytesafe Web Console. Credentials are stored in ~/.npmrc.

 $ npm login 

c. Install your npm packages. The command below is an example and installs react. The Bytesafe Web Console shows React’s all dependencies that are downloaded into your registry “default”.

$ npm install react

Note: that you might want to install using “-- no-cache” to really make sure that your private registry is used and not your local cache

That’s it!

Hope you’ll enjoy your private registries. For more details on using Bytesafe, check out this post Using Bytesafe — The Basics.

Happy coding!

Cover photo by Leone Venter on Unsplash

Originally published at https://dev.to on May 8, 2020.

--

--

Daniel Parmenvik

Founder of https://bytesafe.dev/. Passionate about code that makes a difference. Geeky about food and enjoy playing music.