From cb0698ea1e47ff5c1f6982afa777b48cc48bf429 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 10:45:21 +0000 Subject: [PATCH] npm Connect panel: show the replace-registry-host command An npm repository's Connect sidebar lists `npm config set registry` and the scoped variant; it now also offers `npm config set replace-registry-host `, so a package-lock.json written against another registry downloads its tarballs through this one. npm rewrites registry.npmjs.org URLs by itself; another registry's host it has to be told. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012e6DJXfcjjRxskuvtSWDNo --- docs/changes/2.2.0/npm-replace-registry-host.feature.md | 4 ++++ web/src/components/PackageConnect.test.ts | 1 + web/src/components/PackageConnect.tsx | 7 +++++++ 3 files changed, 12 insertions(+) create mode 100644 docs/changes/2.2.0/npm-replace-registry-host.feature.md diff --git a/docs/changes/2.2.0/npm-replace-registry-host.feature.md b/docs/changes/2.2.0/npm-replace-registry-host.feature.md new file mode 100644 index 00000000..68e6d074 --- /dev/null +++ b/docs/changes/2.2.0/npm-replace-registry-host.feature.md @@ -0,0 +1,4 @@ +An npm repository's **Connect** panel in the web UI also shows +`npm config set replace-registry-host `, which has npm +download the tarballs of a `package-lock.json` written against another +registry through the repository instead. diff --git a/web/src/components/PackageConnect.test.ts b/web/src/components/PackageConnect.test.ts index 8ed725c3..3b39e37e 100644 --- a/web/src/components/PackageConnect.test.ts +++ b/web/src/components/PackageConnect.test.ts @@ -27,6 +27,7 @@ describe('connectSnippets', () => { expect(snippets.map((s) => s.command)).toEqual([ 'npm config set registry https://f.example/repository/npm-all/', 'npm config set @:registry https://f.example/repository/npm-all/', + 'npm config set replace-registry-host ', 'npm login --registry https://f.example/repository/npm-all/', ]) expect( diff --git a/web/src/components/PackageConnect.tsx b/web/src/components/PackageConnect.tsx index 14c7daf2..df307ff2 100644 --- a/web/src/components/PackageConnect.tsx +++ b/web/src/components/PackageConnect.tsx @@ -91,6 +91,13 @@ export function connectSnippets( command: `npm config set @:registry ${url}/`, copyLabel: 'Copy scope-registry command', }, + { + // npm rewrites a lockfile's registry.npmjs.org URLs onto `registry` + // by itself; another registry's host it has to be told. + label: 'Install a package-lock.json written against another registry', + command: 'npm config set replace-registry-host ', + copyLabel: 'Copy replace-registry-host command', + }, { label: 'Sign in', command: `npm login --registry ${url}/`,