loading...

npm install private-package

joeymink profile image Joey Mink ・2 min read

Not everyone can commit code publicly to GitHub and publish packages to npmjs.com. We all benefit from those who do, no doubt. But many of us apply those generous offerings to (and write fresh code for) internal, private projects.

However, that is no excuse to develop large, monolithic internal projects. I declare: modularization and implementation of independent packages is still necessary! Keep projects narrowly-focused. Write independent, useful, reusable packages!

uh, okay idealogical goofball. HTF am I supposed to conveniently make use of private packages when I can't just npm install my-super-secret-pkg?
^ Nay-sayer

Ah, but you can! Read on...

Sonatype has a product called Nexus. It's a well-known Maven (Java) repository you can run privately. But get this: it's not just a private Maven repository 😮 It's also a private PyPi repository, and ... wait for it ... a private npm repository 🎉👏 And it's free!

Details about configuring Nexus for npm repositories can be found here. Note that you can easily set it up to proxy npmjs.com and host your private packages at the same time ❤️

This has been crucial in recent projects for me. An electron application we've been developing included lots of complex, independent algorithms that deserved their own projects to house documentation and tests. Rather than bloat the electron project with in-the-weeds details, I was able to put those weeds in their own npm packages and have already begun reusing them in other applications.

If your situation enables it, please keep posting your magic to npmjs.com. We all benefit! But if you can't, running a private repo is a must!

Discussion

pic
Editor guide
Collapse
nektro profile image
Collapse
joeymink profile image
Joey Mink Author

I have! But it gets pricey at $16/mo/user.

Collapse
nektro profile image
Meghan (she/her)

Nexus is still better here as it’s free but it’ll you don’t want to deal with the hassle of hosting? npm orgs is only $7/mo/user