Skip to content

[rush-lib] Update [dot]npmrc #5296

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[rush-lib] Update [dot]npmrc #5296

wants to merge 3 commits into from

Conversation

L-Qun
Copy link
Contributor

@L-Qun L-Qun commented Aug 5, 2025

Since https://registry.npmjs.org/ is already the default npm registry, there's no need to configure it explicitly. Otherwise, it will override the user's local configuration

Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
@iclanton
Copy link
Member

iclanton commented Aug 6, 2025

The repo maintainer generally wants to control which registry the repo talks to explicitly, so overriding whatever the user has configured is the desired behavior. For example, this repo explicitly uses the public registry because it's an OSS project. If a developer has a private registry configured that does not have the public registry configured as an upstream and runs rush install, their installation is likely to fail.

@iclanton iclanton moved this from Needs triage to In Progress in Bug Triage Aug 6, 2025
@L-Qun
Copy link
Contributor Author

L-Qun commented Aug 6, 2025

@iclanton The public npm registry (https://registry.npmjs.org/) is the default registry for all standard npm and pnpm setups. Unless a developer has explicitly changed it, it will be used automatically. Hardcoding it provides no additional benefit.

@iclanton
Copy link
Member

iclanton commented Aug 6, 2025

The additional benefit is the repo owner ensuring that an individual user's override isn't used.

@L-Qun
Copy link
Contributor Author

L-Qun commented Aug 7, 2025

@iclanton But doesn't it introduce even bigger problems? Users typically won’t notice this configuration after generation, but they’ll have to spend time later figuring out why things are failing. Usually, every company has its own registry, which means as long as they run this command, they’re guaranteed to run into issues.

@@ -24,7 +24,7 @@
#

# Explicitly specify the NPM registry that "rush install" and "rush update" will use by default:
registry=https://registry.npmjs.org/
# registry=https://registry.npmjs.org/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 There was originally some reason why this was needed, maybe for Azure DevOps? I will ask some other maintainers about it at Rush Hour tomorrow.

Copy link
Collaborator

@octogonz octogonz Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think the problem is like this:

1. Person A has no ~/.npmrc user file on their computer. They run rush update --full, so the pnpm-lock.yaml file is created using versions from registry=https://registry.npmjs.org/. Let's say this is the correct behavior.

2. Person B is working in some other repository, where they are instructed to configure a private registry in their ~/.npmrc user file.

3. Next, Person B clones the monorepo and runs rush install. It mostly works, because the private registry has most of the same packages as npmjs.org. But a few versions are missing, maybe because a security policy delays syncing of very new versions.

4. Thus, for Person B, rush install prints a confusing error about missing versions. Why is it broken?

5a. Person B asks for on call support. Person A tries to reproduce the error, but "it works fine for me" (because they are missing the .npmrc file).

- OR -

5b. Person B "fixes" the problem by running rush update --full. Now the lockfile matches their registry. But when they create a pull request, it fails in CI, because the CI machine has no ~/.npmrc user file. What??

The core problem is that rush install is not behaving deterministically. Ideally there should be no ~/.npmrc at all, but 90% of the common problems can be avoided by explicitly specifying registry= in common/config/rush/.npmrc.

Of course, having the wrong default in common/config/rush/.npmrc will also cause confusion, but that's still better than nondeterministic errors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users typically won’t notice this configuration after generation, but they’ll have to spend time later figuring out why things are failing. Usually, every company has its own registry, which means as long as they run this command, they’re guaranteed to run into issues

@L-Qun The problem you're describing here, it only happens when someone is creating a new monorepo, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@octogonz Creating a new subspace

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

Successfully merging this pull request may close these issues.

3 participants