<h3 dir="auto">Current Behavior:</h3>
<p dir="auto">If you have a package with <code class="notranslate">something</code> in <code class="notranslate">peerDependencies</code> and then install that something in the same package as a devDependency, the peerDependencies field is changed and the dependency is added to <code class="notranslate">package.json</code>, but it inherits the semver string that the peer dependency had.</p>
<h3 dir="auto">Expected Behavior:</h3>
<p dir="auto">Installing a dev dependency should do the same change to the <code class="notranslate">package.json</code>, whether that dependency is already in <code class="notranslate">peerDependencies</code> or not.</p>
<h3 dir="auto">Steps To Reproduce:</h3>
<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="echo '{ &quot;peerDependencies&quot;: { &quot;typescript&quot;: &quot;*&quot; } }' &gt; package.json
npm i -D typescript
cat package.json"><pre class="notranslate"><span class="pl-c1">echo '{ "peerDependencies": { "typescript": "*" } }' &gt; package.json</span>
<span class="pl-c1">npm i -D typescript</span>
<span class="pl-c1">cat package.json</span></pre></div>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{&quot;peerDependencies&quot;:{&quot;typescript&quot;:&quot;^4.2.4&quot;},&quot;devDependencies&quot;:{&quot;typescript&quot;:&quot;*&quot;}}"><pre class="notranslate">{<span class="pl-ent">"peerDependencies"</span>:{<span class="pl-ent">"typescript"</span>:<span class="pl-s"><span class="pl-pds">"</span>^4.2.4<span class="pl-pds">"</span></span>},<span class="pl-ent">"devDependencies"</span>:{<span class="pl-ent">"typescript"</span>:<span class="pl-s"><span class="pl-pds">"</span>*<span class="pl-pds">"</span></span>}}</pre></div>
<h3 dir="auto">Environment:</h3>
<ul dir="auto">
<li>OS: macOS</li>
<li>Node: 15.14.0</li>
<li>npm: 7.10.0</li>
</ul>
<h3 dir="auto">Current Behavior:</h3>
<ol dir="auto">
<li>package that has:</li>
</ol>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;peerDependencies: {
  &quot;webpack&quot;: &quot;&gt;=1.11.0&quot;
},
&quot;devDependencies&quot;: {
  &quot;webpack&quot;: &quot;^4&quot;
},"><pre class="notranslate"><span class="pl-ii">"peerDependencies: {</span>
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>&gt;=1.11.0<span class="pl-pds">"</span></span>
<span class="pl-ii">},</span>
<span class="pl-ent">"devDependencies"</span>: {
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>^4<span class="pl-pds">"</span></span>
},</pre></div>
<ol start="2" dir="auto">
<li>run <code class="notranslate">npm install --save-dev webpack@3</code></li>
<li>see package.json updated to:</li>
</ol>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;peerDependencies: {
  &quot;webpack&quot;: &quot;^3.12.0&quot;
},
&quot;devDependencies&quot;: {
  &quot;webpack&quot;: &quot;^3&quot;
},"><pre class="notranslate"><span class="pl-ii">"peerDependencies: {</span>
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>^3.12.0<span class="pl-pds">"</span></span>
<span class="pl-ii">},</span>
<span class="pl-ent">"devDependencies"</span>: {
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>^3<span class="pl-pds">"</span></span>
},</pre></div>
<h3 dir="auto">Expected Behavior:</h3>
<p dir="auto">The package.json should become:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;peerDependencies: {
  &quot;webpack&quot;: &quot;&gt;=1.11.0&quot;
},
&quot;devDependencies&quot;: {
  &quot;webpack&quot;: &quot;^3&quot;
},"><pre class="notranslate"><span class="pl-ii">"peerDependencies: {</span>
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>&gt;=1.11.0<span class="pl-pds">"</span></span>
<span class="pl-ii">},</span>
<span class="pl-ent">"devDependencies"</span>: {
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>^3<span class="pl-pds">"</span></span>
},</pre></div>
<p dir="auto">or:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;peerDependencies: {
  &quot;webpack&quot;: &quot;&gt;=1.11.0&quot;
},
&quot;devDependencies&quot;: {
  &quot;webpack&quot;: &quot;^3.12.0&quot;
},"><pre class="notranslate"><span class="pl-ii">"peerDependencies: {</span>
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>&gt;=1.11.0<span class="pl-pds">"</span></span>
<span class="pl-ii">},</span>
<span class="pl-ent">"devDependencies"</span>: {
  <span class="pl-ent">"webpack"</span>: <span class="pl-s"><span class="pl-pds">"</span>^3.12.0<span class="pl-pds">"</span></span>
},</pre></div>
<p dir="auto">but since i didn't use <code class="notranslate">--save-peer</code> (or <code class="notranslate">--save</code> by itself, even), the peer dep <em>must not be touched</em>.</p>
<p dir="auto">Separately, this is an entirely unexpected breaking change in my package, since some potential valid peer versions are now invalid, so this could be quite dangerous.</p>
<h3 dir="auto">Steps To Reproduce:</h3>
<p dir="auto">see "current behavior"</p>
<h3 dir="auto">Environment:</h3>
<ul dir="auto">
<li>Node: 15.8.0</li>
<li>npm: 7.5.3</li>
</ul>