<h3 dir="auto">Is there an existing issue for this?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the existing issues</li>
</ul>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto"><code class="notranslate">package-lock.json</code> uses private verdaccio endpoint for the <code class="notranslate">resolved</code> field as opposed to the NPM registry.</p>
<p dir="auto">One work around for this is to do a find all and replace in the <code class="notranslate">package-lock.json</code> whenever you run <code class="notranslate">npm i</code>. But that is a real hassle.</p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">There to be an option to not use the private verdaccio endpoint for the <code class="notranslate">resolved</code> field so when other users run <code class="notranslate">npm i</code> they don't run into errors.</p>
<h3 dir="auto">Steps To Reproduce</h3>
<ol dir="auto">
<li>Set <code class="notranslate">.npmjs</code> to <code class="notranslate">registry=http://thisismyprivateverdaccioendpoint.com/</code></li>
<li>Create a project (<code class="notranslate">npm init</code>)</li>
<li>Run <code class="notranslate">npm i --save express</code> (or any package)</li>
<li>Notice how <code class="notranslate">package-lock.json</code> will have the <code class="notranslate">resolved</code> property set to the registry set in <code class="notranslate">.npmjs</code></li>
<li>Send project to someone else without node_modules folder</li>
<li>Have them run <code class="notranslate">npm i</code></li>
<li>Notice that there is an error</li>
</ol>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>OS: macOS 12.0 Beta (21A5268h)</li>
<li>Node: v16.4.2</li>
<li>npm: 7.18.1</li>
</ul>
<h3 dir="auto">Is there an existing issue for this?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the existing issues</li>
</ul>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">When installing a scoped modules using a private registry that returns resolved URLs that point at the public registry, npm 7 rewrites the resolved url to point at the private registry.</p>
<p dir="auto">For example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm i --registry=http://localhost:8080 --cache=empty  @babel/helper-validator-identifier"><pre class="notranslate"><code class="notranslate">npm i --registry=http://localhost:8080 --cache=empty  @babel/helper-validator-identifier
</code></pre></div>
<p dir="auto">results in</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm ERR! code E404
npm ERR! 404 Not Found - GET http://localhost:8080/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.5.tgz"><pre class="notranslate"><code class="notranslate">npm ERR! code E404
npm ERR! 404 Not Found - GET http://localhost:8080/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.5.tgz
</code></pre></div>
<p dir="auto">Despite the fact that:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm v --registry=http://localhost:8080 --cache=empty @babel/helper-validator-identifier dist.tarball"><pre class="notranslate"><code class="notranslate">npm v --registry=http://localhost:8080 --cache=empty @babel/helper-validator-identifier dist.tarball
</code></pre></div>
<p dir="auto">shows</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.5.tgz"><pre class="notranslate"><code class="notranslate">https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.5.tgz
</code></pre></div>
<p dir="auto">This happens with and without lockfiles but only happens with scoped modules and an empty cache (as having the content hash in the cache means that network requests are skipped).</p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">I would expect npm to not rewrite resolved urls.</p>
<p dir="auto">If it were to rewrite resolved urls is intended, I would expect it the same for scoped and unscoped packages. (But I would much prefer that it didn't.)</p>
<h3 dir="auto">Steps To Reproduce</h3>
<ol dir="auto">
<li><code class="notranslate">git clone https://github.com/iarna/repro-resolved-rewrite</code></li>
<li><code class="notranslate">cd repro-resolved-rewrite</code></li>
<li><code class="notranslate">npm it</code></li>
</ol>
<h3 dir="auto">Environment</h3>
<p dir="auto">Tested on:<br>
OS: Debian<br>
node: 16.4.2<br>
npm: 7.18.1, 7.19.1</p>