-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for configuring different repositories for scopes #24
Comments
This would be a very useful feature if xpm supported the various registry configuration methods npm supports. Is this still planned to be supported?
|
Yes, it is still planned, but for now I'm not sure exactly what needs to be done. xpm uses exactly the same modules to access the packages as npm, so, with the proper configuration, I expected they both behave the same, but I had no time to further investigate. As a temporary workaround, you can refer private git or ftp resources, as you can with npm. |
I investigated on my local setup how to get this to work. The problem appears with not passing proper options to pacote methods. To get a package to install from a private registry, I had to at least pass a 'registry' option to pacote.manifest() and pacote.extract() as seen in the below images. I didn't thoroughly test this, I only tested that it would install the package from a private registry I setup locally. From what I understand of the npm code they handle things a bit differently, but the idea is similar. It seems npm has a Also, npm seems to store a resolved link to the package in their package-lock which is probably used for future installs. |
Can you clarify how you defined your custom npm configuration to access the local registry? Can you determine what options does npm pass to pacote in this setup? Actually I'd be interested to know what npm passes to pacote in a use case with multiple selective registries, configured via I remember long time ago I tried to understand if npm does check the configuration itself to determine the proper registry for a package, or passes some global configuration to pacote, which later does the registry selection, but I did not reach any conclusion. |
Did you really install a local server on port 4873, or it is just an example. If you did, what server did you use? |
I was testing this on a local server. I was testing this out using verdaccio (https://verdaccio.org/). The setup is quite simple. |
I used both 'npm set registry http://localhost:4873/' and 'npm config set @my-scope:registry http://localhost:4873/'
I was not able to find how to enable debug/trace in npm. If you know how to do this, I can find out what options are passed to pacote. |
I was able to get npm to show me the options. In this scenario, I have set a scope specific registry using '@Myscope' using 'npm config set @Myscope:registry http://localhost:4873/'. What is interesting is that the options still have registry pointing to registry.npmjs.org. That makes sense because I did not globally change registry. Also, the options include '@Myscope:registry': 'http://localhost:4873' which I also expected to see. What is not obvious to me is how the scope specific registry is resolved. The pacote docs don't seem to indicate it would use the scope specific registry option. However, I did see an option for this in the Arborist docs (https://github.com/npm/arborist). I'm not too familiar with Arborist though. |
I did not check, but I guess pacote passes the options to arborist. Anyways, it appears that npm does not the selection itself, so xpm should not do it either. The question now is how to get the I think that using separate xpm configuration files for these options doesn't make much sense, probably parsing the npm configuration files would be more appropriate. |
Agreed, reading the options from the global/user/project npmrc files, and passing those to pacote seems to be the right solution. |
npm can be configured with something like
in
.npmrc
ornpm config
.xpm should use these definitions too, and access the correct server.
The text was updated successfully, but these errors were encountered: