<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">I have <code class="notranslate">prettier-plugin-packagejson</code> installed (which has <code class="notranslate">sort-package-json@1.51.0</code> as a dependency)</p>
<p dir="auto">And trying to run <code class="notranslate">npx sort-package-json@1.48</code> because I want to use version 1.48, before <a href="https://github.com/keithamus/sort-package-json/pull/206" data-hovercard-type="pull_request" data-hovercard-url="/keithamus/sort-package-json/pull/206/hovercard">this tragic PR was merged</a></p>
<p dir="auto">But npx picks up version 1.51.0 which is in my local deps, and in PATH. But it's the wrong version.</p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">npx should make sure that it's running version <code class="notranslate">1.48</code>, as requested.</p>
<h3 dir="auto">Steps To Reproduce</h3>
<ol dir="auto">
<li>Make sure <code class="notranslate">sort-package-json</code> is not installed globally (<code class="notranslate">npm rm sort-package-json</code>)</li>
<li>Make sure it's not in PATH: <code class="notranslate">which sort-package-json</code> should not return anything</li>
<li>Do <code class="notranslate">npm init</code></li>
<li>Add these two scripts in <code class="notranslate">package.json</code>:
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;z&quot;: &quot;should be last&quot;,
&quot;a&quot;: &quot;should be first&quot;"><pre class="notranslate"><code class="notranslate">"z": "should be last",
"a": "should be first"
</code></pre></div>
</li>
<li>Do <code class="notranslate">npm i prettier-plugin-packagejson</code></li>
<li>Run <code class="notranslate">npx sort-package-json@1.48</code></li>
<li>Observe scripts still not sorted, because 1.51 was used (<code class="notranslate">cat package.json</code>, see "z" will be still before "a")</li>
</ol>
<p dir="auto">Optional:</p>
<ol start="8" dir="auto">
<li>Remove local deps: <code class="notranslate">rm -rf ./node_modules/</code></li>
<li>Run <code class="notranslate">npx sort-package-json@1.48</code> again</li>
<li>Observe scripts are now sorted because 1.48 was used (<code class="notranslate">cat package.json</code>, see "a" will be before "z")</li>
</ol>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>OS: Ubuntu 20 (WSL)</li>
<li>Node: 16.7.0</li>
<li>npm: 7.19.0</li>
</ul>
<h3 dir="auto">Current Behavior:</h3>
<p dir="auto">running <code class="notranslate">npx @package@version</code> generate it with the current install version</p>
<h3 dir="auto">Expected Behavior:</h3>
<p dir="auto">it should be generated with the given version</p>
<h3 dir="auto">Steps To Reproduce:</h3>
<p dir="auto">ex. steps to reproduce the behavior:</p>
<ol dir="auto">
<li>run <code class="notranslate">npm i -g npm@latest</code> to install npm 7</li>
<li>run <code class="notranslate">npx @angular/cli@next new</code></li>
<li>answer all questions of the angular cli, it doesn't matter what the answers are</li>
<li>it will install angular 11 (while next is 12)</li>
</ol>
<h3 dir="auto">Environment:</h3>
<ul dir="auto">
<li>OS: Windows 10</li>
<li>Node: 14.16.1</li>
<li>npm: 7.12.0 (working fine with 6.14.13)</li>
</ul>