Skip to content
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

Passing registry for different package managers #2320

Open
lunaleaps opened this issue Mar 5, 2024 · 5 comments
Open

Passing registry for different package managers #2320

lunaleaps opened this issue Mar 5, 2024 · 5 comments

Comments

@lunaleaps
Copy link
Contributor

Describe the Feature

Currently we use --yarn-config-options in React Native to e2e testing to use privately published monorepo packages when running our template app tests
See: https://github.com/facebook/react-native/blob/main/scripts/e2e/init-template-e2e.js#L125

We've recently switched to using npm because Yarn v3 doesn't respect the npmRegistryConfig set. See facebook/react-native#43130

yarnConfigOptions is only used when the package manager is yarn -- from my understanding there isn't a way to pass a registry for npm`
See https://github.com/react-native-community/cli/blob/main/docs/commands.md#init

Possible Implementations

Introduce another flag for npm specifically, or let me know if there is a way to do this.

@szymonrybczak
Copy link
Collaborator

szymonrybczak commented Mar 5, 2024

hey @lunaleaps! 👋 to make Yarn working with custom npmRegistryServer we can do it by just adding another argument to --yarn-config-options:

❯ yarn config get npmRegistryServer
Alias tip: y config get npmRegistryServer
https://registry.yarnpkg.com

❯ yarn config set npmRegistryServer localhost:4732
Alias tip: y config set npmRegistryServer localhost:4732
➤ YN0000: Successfully set npmRegistryServer to 'localhost:4732'

So I think that would work for Core's use case for now, right? Let me know if I'm missing something.

Edit: I see @huntie referenced this issue inside Yarn repo, I believe it is fixed inside newer Yarn versions (?) Do you have any CI jobs that are showing that it isn't working? 🤔

@lunaleaps
Copy link
Contributor Author

lunaleaps commented Mar 5, 2024

@szymonrybczak Thanks for looking, my question is how do we set a registry for npm specifically. Because as I understand it using --yarn-config-options only affects using the package manager yarn, is that right?

We want to use npm and use a custom registry. My understanding is that we need a flag like registry <registryhost>

Here is the only place I see where yarnConfigOptions is used:

if (packageManager === 'yarn' && getYarnVersionIfAvailable() !== null) {

CleanShot 2024-03-05 at 11 09 49@2x

@szymonrybczak
Copy link
Collaborator

szymonrybczak commented Mar 5, 2024

@szymonrybczak Thanks for looking, my question is how do we set a registry for npm specifically. Because as I understand it using --yarn-config-options only affects using the package manager yarn, is that right?

Yes, I think we can create also more generic --registry option 👍

I have doubts why you moved there from Yarn to NPM? Since Yarn 3.x seems to support npmRegistryServer as of my testing, do you have any CI jobs that were failing or anything?

@lunaleaps
Copy link
Contributor Author

Yea these are the CI tests that were failing: https://app.circleci.com/pipelines/github/facebook/react-native/42789/workflows/9

CleanShot 2024-03-05 at 14 00 44@2x
d0e9e3f-afac-43c4-be30-e008e8d407da/jobs/1401065?invite=true#step-116-157494_82

It looks like yarn v1.22.19, yea it sounds worthwhile to try upgrading.

@szymonrybczak
Copy link
Collaborator

Yea, because while creating project with CLI we're installing package in temporary path, and in React Native case on CI there's Yarn v1 installed so it is ignoring npmRegistryServer :< Are there any things that blocks upgrading global version in CI? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants