Use a scoped registry per scope
Send each npm scope to its own registry with a scope:registry line in .npmrc, so private and public packages install side by side. npm 10.
A company often has several registries: its own for @acme, GitHub Packages for @labs, and npmjs.org for everything else. Each scope can name its registry in .npmrc.
@acme:registry=https://registry.acme.example.test/
@labs:registry=https://npm.labs.example.test/
//registry.acme.example.test/:_authToken=${ACME_TOKEN}npm config get @acme:registry
npm config get @labs:registryhttps://registry.acme.example.test/
https://npm.labs.example.test/A package named @acme/ui is fetched from the first host, @labs/charts from the second and express from the default registry. Auth lines are matched by host, so only the registries that need a token get one. See the scope documentation.
The scope is part of the package name, so one scope cannot be split across two registries. Names also matter for security: an internal name without a scope may be taken on the public registry by someone else, and npm would fetch theirs.
Scope every internal package, and keep the registry mapping in the project, so CI and laptops resolve the same way.