Recently, we started creating and working with private npm modules at Chiedo Labs. It’s pretty simple but here are the steps.
1. Create an npmjs.org account if you don’t have one
If you already have an account, you can skip this step. Otherwise, you can sign up for a free npmjs.org account here.
2. Login to NPM in your terminal
Run the following command
3. Get access to a private package
If you’re working on a project with an existing private package, ask someone from that project to make you a member of their organization on npmjs.org or add you as a collaborator if they have a solo npm account. Alternatively, if you want to create your own private package, you’ll need to upgrade your account in your profile section. Either to a paid solo account or by creating an organization.
4. Create a Token and Set up your Local Development Environment
You can technically skip this step. But adding this step will make sure things “just work” if your project is configured for deployment to something like Heroku. To save some keystrokes, you can complete this step by working through steps 1-3 of this article.
5. Add the private package to your project
If you’re working on an existing project, you may not need to do anything here. But if you’re adding a new private package to your project, it’s business as usual. The only difference will be that private projects always start with @<scope>/ so for example, all of our packages at Chiedo Labs are installed by running commands like the following:
// yarn add @<scope>/package-name yarn add @chiedolabs/package-one yarn add @chiedolabs/package-two
That’s all folks! If you have any questions or I got anything wrong, let me know in the comments.
We're Hiring‼️ 🚀😄 Looking to join our team of web developers? We're passionate about innovation, family, and community. Apply today!