r/node • u/GeneralReposti_Bot • Oct 14 '19
GitHub Package Registry: Your packages, at home with their code
https://github.com/features/package-registry6
u/pimterry Oct 14 '19
What's the install flow like for end users? I'm considering publishing my open source libraries to GH in addition to npm (and maybe eventually dropping npm entirely).
With npm/yarn it's nice that my README can just say npm install packagename. Is there an equivalently simple command for GH packages, or do I need to give every user instructions to configure the extra registry?
5
u/razer54 Oct 14 '19
It's a 3 step process.
Create an access token and issue `npm login ...`
Specify the scope of package in `.npmrc`
Install your package
I'm a cloud architect in a startup using GH registry, and for us, it's more about being capable to deploy private package for our CI/CD pipeline without any needs of npm enterprise.
But i'm clearly not sure about using it for any public package. Not yet.
2
u/pimterry Oct 14 '19 edited Oct 14 '19
Ehhhhhhhh... This is the kind of UX that puts me off. I really want to use GH for public packages! Required login for every install is a big pain though, just for starters.
That's not to say I wouldn't use this to publish internal packages at work, but for community-targetted packages this feels like a non-starter for now, which is a shame.
4
u/moggg Oct 14 '19
You just need a token in your .npmrc file and it logs in for you when you do the install, it should be invisible once it’s been initially setup
6
u/pimterry Oct 14 '19
Yeah, and that's great if you're using it already because your company does everything on GH, or once GH becomes sufficiently popular that everybody is logged in already.
Right now though, 99% of npm users aren't logged in, so this is an annoying extra pain point for them if your package is published on GitHub packages instead of npm.
2
u/MadeWithPat Oct 14 '19
Not sure exactly what you mean by “login for every install”. Unless it’s different from other private/self hosted registries, setup should be a one time thing, like how you have to set up git on a new machine.
5
u/pimterry Oct 14 '19
I should've been clearer: I mean a login for every user who needs to install the package (assuming they're not already logged into GitHub's registry, but that's a safe bet for the moment), not for every install by one user.
Even if the login is one time though, users need to configure the registry separately for each @scope they use, which is potentially for each package you use. The npm client can only have one default registry, and there's a different registry URL for each GH org. If I'm installing a bunch of community packages then that's an annoying extra step, even if I'm logged in already.
The GH docs do call this out: https://help.github.com/en/articles/configuring-npm-for-use-with-github-package-registry#installing-packages-from-other-organizations. Imagine a world where all packages are published on GH, by all sorts of different orgs. Messing with this config gets super annoying super quickly. You could fix this in the npm client somehow of course, but it's not fixed today.
4
u/MadeWithPat Oct 14 '19
Ah. I agree with you there. In general, I don’t really see the value of a separate registry for public packages.
Edit: and assuming private packages are a paid service, I’m not sure I see the value in using github’s registry at all over npm.
1
Oct 15 '19
I’ll verify this tomorrow when I’m back at my computer, but this should only apply for private packages. For public packages you shouldn’t need to configure anything beyond specifying the registry.
1
u/razer54 Oct 15 '19
That would make sense indeed. But it's not clearly stated in documentation.
But anyway, that would still require people to play with registry.
That what's happen when the package registry is held by a private company...
1
Oct 15 '19
Not surprising, given it’s in beta. You can link NPM modules via a repo notation as is (
npm i —save someowner/repo), so this is nothing new. They might add the ability to do it using some neat package/publish tricks.Personally I see this less as an NPM replacement and more (like you) as an NPME alternative. We use Verdaccio right now, but I’m looking forward to switching for the access control alone.
1
u/razer54 Oct 15 '19
Beware, it's not production ready (beta indeed....). It happened once or twice that we were unable to push any package for ~8h.
1
Oct 15 '19
Yep, I’m fully aware. I’ve been using it for my personal GH to test in preparation for a move.
1
u/Gehinnn Oct 14 '19
What is this for? Just beeing a workaround for npm enterprise seems to be a little unfair to npm.
What are the advantages to npm besides being free?
4
Oct 14 '19
Why unfair? npm [the CLI] is open source and designed for use with any registry. npm [the company] has a registry you can use but you are not locked into it.
1
u/Remootion Oct 14 '19
This is news to me. I should look deeper into npm, thank you for this info stranger.
1
u/Gehinnn Oct 14 '19
Unfair, cause npm [the company] clearly used/uses the money from their paid registry to develop npm [the CLI]. Github doesn't.
-7
u/hopfield Oct 14 '19
Honestly I don’t see this gaining much traction over NPM. Why would you use this instead of NPM?
12
u/j_schmotzenberg Oct 14 '19
Private npm scopes are expensive. Lots of orgs already pay for private Github or GHE.
7
u/highres90 Oct 14 '19
Yeah we're using GH Actions and Package Registry for everything now. It's a really nice experience having everything in one place and not spread out over multiple services. Managing users and access is greatly simplified because of this too.
1
u/mesta_ Oct 14 '19
How do you manage installing in a project A a private dependency generated by a build in a repo B? There is an opened issue about it in github actions repo, but still no solution.
1
u/highres90 Oct 14 '19
Is this the issue where the GitHub token they provide can publish packages but can't install them from other repos? In order to get around that you create a token on your account with read/write access to the package registry and use that instead. It's in either their docs or the issue thread you're on about 🙂
1
u/mesta_ Oct 14 '19
Yes, this issue.
We, me and coworkers, manage it this way, yeah. Creating an "integration" Github account and generate a token but I'm not satisfied by this.
Anyway, better solutions will come with release of GPR and Github Actions I guess!
2
u/highres90 Oct 14 '19
Yeah they're ok about making the GitHub token support installing packages in your orgs scope which makes sense and will solve the problem
0
14
u/Nrdrsr Oct 14 '19
Do they offer signed packages? I feel like that solves a subset of the problems with npm