npm
is very good at supporting packages publishes to the global/central npm
repo, which doesn't work well for private, application code. npm
also supports adding a git repo as a dependency, which lets you have a private dependency.
The problem is, as I understand to be best practice, my npm
packages tend to be very tight and small, whereas my git repos tend to be larger, and will include several npm
packages. I do not know any way to attain this granularity while pointing to a github URL. How to solve this?
UPDATE
I accepted the answer that says "don't do this, stay on the rails." I agree with this recommendation, but YMMV.
With npm private packages, you can use the npm registry to host code that is only visible to you and chosen collaborators, allowing you to manage and use private code alongside public code in your projects. Private packages always have a scope, and scoped packages are private by default.
If you want to host a private NPM package but do not want to pay US$ 7 per user, per month to host it directly at https://www.npmjs.com/ this post is for you. Here I will share a very practical way you can host it privately for free at Github Packages Registry + NPM.
When we install a package using the npm install package-name command, it will download the current stable version of the package inside node_modules folder and add it to package. json file. To install multiple versions of the same package, we need to use the package alias syntax which is supported from the npm v6.
I would suggest that one repo with multiple packages is a bad idea to start with for several reasons. You should be viewing a package as its own entity: independently built, tested, and deployed. All that to say, each package should live in its own repo.
That being said, I definitely understand the benefit of being able to do an npm install <package-group>
of one "commons" package and have it grab all the packages you need in one shot. I would suggest looking at the grunt-contrib model for accomplishing this. In short, they have a bunch of grunt-contrib- packages (ex. grunt-contrib-coffee) each living in their own repositories. They then create a separate repository that defines the parent "grunt-contrib" package. All this parent package does is specify dependencies on all of the sub-packages. This allows you to do an npm install grunt-contrib-coffee
(for example) and get just the grunt-contrib-coffee package; or you can do npm install grunt-contrib
and get their entire suite all in one shot.
Hope this helps!
You could also set up your own local npm repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With