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}/`,