-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling of multiple npm servers #547
Comments
I don't think this would work very well since the only way you can host your own registry is via npm enterprise which already handles this. Scopes and private packages are the solution to hosting your own packages. |
Says who? 😛 npm server just returns JSON and tarballs, there's no reason you couldn't host your own. You could fairly easily build your own like I did for NuGet with Simple NuGet Server. There's already software packages like sinopia (or its more well-maintained fork verdaccio) to handle it, too. sinopia/verdaccio handle caching of npm packages too, but a simple npm server that could be used with Yarn could avoid doing that and instead just serve the custom packages. |
I have a mildly unsatisfying experience with sinopia. |
In order to replicate the npm registry you need to implement a bunch of CouchDB endpoints. How would this interact with commands like |
Afaik Sinopia implements publish command and other public api. On Friday, 7 October 2016, Sebastian McKenzie notifications@github.com
|
I just used it as an example, I'm sure there's better solutions. Nexus Repository Manager supports it too, for example (at Facebook we have a Nexus server for Java stuff + an internal Maven mirror)
It doesn't have to be CouchDB specifically though, you just need something that returns data in the same format. NuGet uses OData for its old API, but I didn't use a proper OData server for my custom server, I just hacked something together in PHP.
NuGet's config has a default package source that it publishes to, and you can override it when publishing the package (eg. |
We use a private NPM mirror/registry at my company. Currently we have a .npmrc file in the project directory, which Yarn seems to use (the registry url is correct in "info npm config"). However, |
Just dropping a note here: Sinopia acts as a caching proxy to the official NPM registry, and layers its own local registry overtop. It implements the same CouchDB API but does not do any replication of CouchDB data. I wouldn't go so far as to call Sinopia stable, but we've been relying on it for almost 3 years now and have hundreds of modules published there. |
same here, Sinopia user. would love to see yarn support! |
Our private registry is proget with the npm feed type. We use scoped packages for our private stuff. I wasn't able to get the |
Note that this issue is specifically for allowing the usage of multiple different servers (for example, the public npm server for some packages, and a private server for others). Allowing a single different server to be set (for example, if you have a caching proxy, or something like Sinopia that's both a package server and a proxy) is covered by #606. Thanks! |
Same thing, currently, it seems I can access either the private repo or npm, but not both. Granted, I've been using this for about 20 minutes, so maybe I've done something wrong. Current setup, I have a .yarnrc file with:
|
I think I have the same issue as @nikolasleblanc |
We use Sinopia like @developit as both a caching server, and a private npm registry, with about 40 devs. It's been rock solid for almost 2 years now so (just as another data point). Setting registry in .yarnrc seems to work, but it would be nice if yarn simply respected npm configuration for the default registry. |
Artifactory can also host a private registry. |
@kittens @bestander would be happy to lend a helping hand on this feature, in my copious amounts of OSS time -- one issue that immediately comes to mind is that we have special Varnish rules for scoped modules at npm, such that private content is never cached in our CDN ... before implementing private module support, there might need to be some additional logic added to the CloudFlare CDN fronting registry.yarnpkg.com. What's the best way forward with work on this feature, should an RFC be drafted? Update
|
We can not replace bower (at least not without some hacks) until the issue [1] is solved. Also note, that as of today private registries requiring authentication can not be used [2] [3]. [1] yarnpkg/yarn#617 (comment) [2] yarnpkg/yarn#606 [3] yarnpkg/yarn#547
It's an excellent discussion and it would be awesome if yarn could solve current problems with using multiple npm repos for in-company development. Here's the typical scenario for a JS project within our organization:
Daily builds publish into development Nexus, production builds install from and publish to production registries. Remember, publishing is always to a different repo than installing from. Currently teams solving this by having:
This is a lot of boilerplate to set up, and even experienced developers still bump into installation failures when they forget that they must run We tried to build some automation around this by switching registries on the fly but only bumped into other npm client peculiarities, such as npm/npm#7771 Now, I don't have any well-thought proposition for solving all these issues. I am adding it here to outline some real-world scenarios and pain that is currently associated with supporting them with npm, so that perhaps this discussion can contribute to yarn improvements. I would personally be happy to contribute if/when there is an agreement on how yarn could work around such issues. |
I think that a lot of us have built workarounds for several of NPM's idiosyncrasies, so I'd ask folks here to be open-minded towards solutions that might not align 100% with the (relatively contrived) ways that we're currently using NPM, and also mindful that we likely have a very wide range of distinct use-cases. I'd also ask the participants in this thread to contribute their experiences with other package managers that have addressed some of NPM's shortcomings (without turning this into a referendum about all of the use-cases that NPM doesn't cover well). So far, I've identified a few themes from others in this thread:
Also, a few thoughts of my own:
|
The way we use this (with Sinopia) the only real concern is that configuration work the same way it does now with npm. Right now we can configure global default registry ( I would argue for compatibility first, rather than codifying more complex use cases that aren't currently supported by |
See #839, which supports private registries the same way npm does. |
@schmod , I second your point about "being open-minded towards solutions that might not align 100% with the (relatively contrived) ways that we're currently using NPM". npm is great for basic use cases, and it would be great to keep 100% compatibility for them so that it could be a drop-in replacement e.g. for nearly any open source project. If you want to win the hearts of those who need a JS package manager for corporate development, then you could definitely do much better than npm. Commenting on your points, here are the immediate big (huge! awesome!) improvements I could see:
Can you elaborate a bit on the idea of CI hooks? Not sure I get how it would work. |
+1 yarn is not working with private npm registries. We are using sinopia. |
At work we're also using the Nexus repository manager. We use it for Maven repositories but for npm as well. For npm our setup is as follows:
Developers all use the virtual registry in their global npm configuration. As pointed out above in this post, there are indeed ugly workarounds that we need to implement to be able to publish/retrieve artifacts to/from different registries using npm. |
Yeah, if we supported multiple servers natively in Yarn, you wouldn't need the "virtual registry" 😄 |
Virtual repositories are still commonly used with build tools (ie. Maven) that natively support multiple repositories. |
npm doesn't support any of the internal registry tools like proget... the problem for us is npm allows an extra hop after fetching something from the registry. This causes npm install to fail on projects of significant complexity like angular-cli |
Anyone know if there's currently any plans to add support for multiple servers in yarn? Looks like this issue's been stagnant for a few months now. |
Not a priority of the core team.
If it is easy to do then send a pr
…On Fri, 24 Mar 2017 at 21:33, Kurt Preston ***@***.***> wrote:
Anyone know if there's currently any plans to add support for multiple
servers in yarn? Looks like this issue's been stagnant for a few months now.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#547 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACBdWGSN-5rLijGbmnbLIRC1id36SxDzks5rpDaogaJpZM4KRQBU>
.
|
This would help with my use-case: I am using TFS 2017 behind a firewall and publishing internal packages (specific to my organization) to the npm feed. However, the TFS npm feed is unable to cache upstream packages because of security restrictions. It would be nice if I could specify a default registry and then a secondary named registry via dot notation.
my .yarnrc would look something like this:
(the above commands already product the above .yarnrc we just need to make yarn install consume the dot separeated named registry) @Daniel15 would you consider working on a PR with me? |
addressing this might require 'sections' the way git configure handles sections |
this is probably the reason why we cannot use yarn in our team. we work at least with 3 different repositories:
it's so easy to solve this issue in npm ( not proxies, scopes only ) with .npmrc file.. Why just not take same format? Thanks! |
Something to consider as a future enhancement, post-launch
It's possible to use custom servers with npm, it's just pretty annoying to handle it. The server is either set globally (via
npm set registry
) or every single time you run a command (via--registry
flag, egnpm install --registry http://www.example.com/ test
). Setting it globally only allows a single server to be selected We should be able to do better than that in Yarn.I like the approach that NuGet takes. It has a default configuration file (
%AppData%\NuGet\NuGet.Config
on Windows) that only has their package source configured by default:However you can easily add your own package sources to it, either by editing that file (which changes it globally) or adding a config to your project (which just changes it for that one project):
How this works is that when you install a package, it looks in the first source to see if it's available there. If not, it continues down the list, and only fails if none of the sources contain the requested package.
Use cases:
Note that this issue is specifically for allowing the usage of multiple different servers (for example, the public npm server for some packages, and a private server for others). Allowing a single different server to be set (for example, if you have a caching proxy, or something like Sinopia that's both a package server and a proxy) is covered by #606. Thanks!
The text was updated successfully, but these errors were encountered: