<h3 dir="auto">Background:</h3>
<p dir="auto">I am an author of a golang project called <a href="https://github.com/osdevisnot/sorvor">sorvor</a> and I wish to distribute golang binaries using NPM so that consumers do not have to install separate toolchain to get sorvor.</p>
<p dir="auto">To achieve this, I've published prebuilt platform specific native binaries to NPM via below packages:<br>
<a href="https://www.npmjs.com/package/sorvor-darwin-64" rel="nofollow">https://www.npmjs.com/package/sorvor-darwin-64</a><br>
<a href="https://www.npmjs.com/package/sorvor-darwin-arm64" rel="nofollow">https://www.npmjs.com/package/sorvor-darwin-arm64</a><br>
<a href="https://www.npmjs.com/package/sorvor-freebsd-64" rel="nofollow">https://www.npmjs.com/package/sorvor-freebsd-64</a><br>
<a href="https://www.npmjs.com/package/sorvor-freebsd-arm64" rel="nofollow">https://www.npmjs.com/package/sorvor-freebsd-arm64</a><br>
<a href="https://www.npmjs.com/package/sorvor-linux-32" rel="nofollow">https://www.npmjs.com/package/sorvor-linux-32</a><br>
<a href="https://www.npmjs.com/package/sorvor-linux-64" rel="nofollow">https://www.npmjs.com/package/sorvor-linux-64</a><br>
<a href="https://www.npmjs.com/package/sorvor-linux-arm" rel="nofollow">https://www.npmjs.com/package/sorvor-linux-arm</a><br>
<a href="https://www.npmjs.com/package/sorvor-linux-arm64" rel="nofollow">https://www.npmjs.com/package/sorvor-linux-arm64</a><br>
<a href="https://www.npmjs.com/package/sorvor-windows-32" rel="nofollow">https://www.npmjs.com/package/sorvor-windows-32</a><br>
<a href="https://www.npmjs.com/package/sorvor-windows-64" rel="nofollow">https://www.npmjs.com/package/sorvor-windows-64</a></p>
<p dir="auto">I am expecting user's to have a single NPM dependency in their <code class="notranslate">package.json</code> for the main package:<br>
<a href="https://www.npmjs.com/package/sorvor" rel="nofollow">https://www.npmjs.com/package/sorvor</a></p>
<p dir="auto">The main package lists all the native packages as optional dependencies  so that and NPM can install appropriate optional dependency for a given platform.</p>
<h3 dir="auto">Current Behavior:</h3>

<p dir="auto">NPM v7.x installs all optional dependencies without checking current OS and CPU arch.</p>
<h3 dir="auto">Expected Behavior:</h3>

<p dir="auto">NPM v7.x should install optional dependencies only for current OS and CPU arch.</p>
<p dir="auto">Note: This works correctly with NPM v6.x</p>
<h3 dir="auto">Steps To Reproduce:</h3>

<p dir="auto">run <code class="notranslate">npm install --save-dev sorvor</code></p>
<h3 dir="auto">Environment:</h3>

<ul dir="auto">
<li>OS: Darwin x86_64</li>
<li>Node: 15.9.0</li>
<li>NPM: 7.5.3</li>
</ul>
<h3 dir="auto">Related Issues:</h3>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="533427558" data-permission-text="Title is private" data-url="https://github.com/npm/cli/issues/558" data-hovercard-type="issue" data-hovercard-url="/npm/cli/issues/558/hovercard" href="https://github.com/npm/cli/issues/558">#558</a><br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="521697861" data-permission-text="Title is private" data-url="https://github.com/npm/cli/issues/475" data-hovercard-type="issue" data-hovercard-url="/npm/cli/issues/475/hovercard" href="https://github.com/npm/cli/issues/475">#475</a></p>
<h3 dir="auto">Current Behavior:</h3>

<p dir="auto">I tested installing a git dependency which has either <code class="notranslate">prepare</code> or <code class="notranslate">prepack</code> script with npm CLI v7.0.0-beta.12 and confirmed the following behaviors.</p>
<ul dir="auto">
<li>a package with a <code class="notranslate">prepare</code> script: <code class="notranslate">devDependencies</code> are <strong>NOT</strong> installed but the <code class="notranslate">prepare</code> script is executed</li>
<li>a package with a <code class="notranslate">prepack</code> script: <code class="notranslate">devDependencies</code> are <strong>NOT</strong> installed and the <code class="notranslate">prepack</code> script is <strong>NOT</strong> executed</li>
</ul>
<h3 dir="auto">Expected Behavior:</h3>

<ul dir="auto">
<li>a package with a <code class="notranslate">prepare</code> script: <code class="notranslate">devDependencies</code> are installed and the <code class="notranslate">prepare</code> script is executed</li>
<li>a package with a <code class="notranslate">prepack</code> script: <code class="notranslate">devDependencies</code> are installed and the <code class="notranslate">prepack</code> script is executed
<ul dir="auto">
<li>Though I've not found any document saying that <code class="notranslate">devDependencies</code> are installed when installing a git dependency with a <code class="notranslate">prepack</code> script and actually <a href="https://github.com/npm/cli/issues/1229" data-hovercard-type="issue" data-hovercard-url="/npm/cli/issues/1229/hovercard">they are not installed even when npm CLI v6 is used</a>, I believe npm should install them since running a <code class="notranslate">prepack</code> script without installing <code class="notranslate">devDependencies</code> does not make sense.</li>
</ul>
</li>
</ul>
<h3 dir="auto">Steps To Reproduce:</h3>
<p dir="auto"><code class="notranslate">prepare</code>:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// https://github.com/kimamula/prepare-test/blob/master/package.json
{
  &quot;name&quot;: &quot;prepare-test&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;main&quot;: &quot;index.js&quot;,
  &quot;scripts&quot;: {
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
    &quot;prepare&quot;: &quot;tsc&quot;
  },
  &quot;keywords&quot;: [],
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;devDependencies&quot;: {
    &quot;typescript&quot;: &quot;^4.0.3&quot;
  }
}"><pre class="notranslate"><span class="pl-ii">// https://github.com/kimamula/prepare-test/blob/master/package.json</span>
{
  <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>prepare-test<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1.0.0<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"description"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"main"</span>: <span class="pl-s"><span class="pl-pds">"</span>index.js<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"scripts"</span>: {
    <span class="pl-ent">"test"</span>: <span class="pl-s"><span class="pl-pds">"</span>echo <span class="pl-cce">\"</span>Error: no test specified<span class="pl-cce">\"</span> &amp;&amp; exit 1<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"prepare"</span>: <span class="pl-s"><span class="pl-pds">"</span>tsc<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"keywords"</span>: [],
  <span class="pl-ent">"author"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"license"</span>: <span class="pl-s"><span class="pl-pds">"</span>ISC<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>^4.0.3<span class="pl-pds">"</span></span>
  }
}</pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ npm install github:kimamula/prepare-test
npm ERR! code 127
npm ERR! git dep preparation failed
npm ERR! command /Users/kenji/.nodenv/versions/12.18.3/bin/node /Users/kenji/.nodenv/versions/12.18.3/lib/node_modules/npm/bin/npm-cli.js install --only=dev --prod --ignore-prepublish --no-progress --no-save --cache=/Users/kenji/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --before=
npm ERR! &gt; prepare-test@1.0.0 prepare
npm ERR! &gt; tsc
npm ERR! npm WARN invalid config before=&quot;&quot; set in command line options
npm ERR! npm WARN invalid config Must be one of: null, valid Date string
npm ERR! sh: tsc: command not found
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /Users/kenji/.npm/_cacache/tmp/git-clone-a73f300b
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c tsc
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /Users/kenji/.npm/_cacache/_logs/2020-09-27T06_13_19_941Z-debug.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kenji/.npm/_logs/2020-09-27T06_13_19_972Z-debug.log"><pre class="notranslate">$ npm install github:kimamula/prepare-test
npm ERR<span class="pl-k">!</span> code 127
npm ERR<span class="pl-k">!</span> git dep preparation failed
npm ERR<span class="pl-k">!</span> <span class="pl-c1">command</span> /Users/kenji/.nodenv/versions/12.18.3/bin/node /Users/kenji/.nodenv/versions/12.18.3/lib/node_modules/npm/bin/npm-cli.js install --only=dev --prod --ignore-prepublish --no-progress --no-save --cache=/Users/kenji/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --before=
npm ERR<span class="pl-k">!</span> <span class="pl-k">&gt;</span> prepare-test@1.0.0 prepare
npm ERR<span class="pl-k">!</span> <span class="pl-k">&gt;</span> tsc
npm ERR<span class="pl-k">!</span> npm WARN invalid config before=<span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span> <span class="pl-c1">set</span> <span class="pl-k">in</span> <span class="pl-c1">command</span> line options
npm ERR<span class="pl-k">!</span> npm WARN invalid config Must be one of: null, valid Date string
npm ERR<span class="pl-k">!</span> sh: tsc: <span class="pl-c1">command</span> not found
npm ERR<span class="pl-k">!</span> npm ERR<span class="pl-k">!</span> code 127
npm ERR<span class="pl-k">!</span> npm ERR<span class="pl-k">!</span> path /Users/kenji/.npm/_cacache/tmp/git-clone-a73f300b
npm ERR<span class="pl-k">!</span> npm ERR<span class="pl-k">!</span> <span class="pl-c1">command</span> failed
npm ERR<span class="pl-k">!</span> npm ERR<span class="pl-k">!</span> <span class="pl-c1">command</span> sh -c tsc
npm ERR<span class="pl-k">!</span> 
npm ERR<span class="pl-k">!</span> npm ERR<span class="pl-k">!</span> A <span class="pl-c1">complete</span> log of this run can be found in:
npm ERR<span class="pl-k">!</span> npm ERR<span class="pl-k">!</span>     /Users/kenji/.npm/_cacache/_logs/2020-09-27T06_13_19_941Z-debug.log

npm ERR<span class="pl-k">!</span> A <span class="pl-c1">complete</span> log of this run can be found in:
npm ERR<span class="pl-k">!</span>     /Users/kenji/.npm/_logs/2020-09-27T06_13_19_972Z-debug.log</pre></div>
<p dir="auto"><code class="notranslate">prepack</code>:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// https://github.com/kimamula/prepack-test/blob/master/package.json
{
  &quot;name&quot;: &quot;prepack-test&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;main&quot;: &quot;index.js&quot;,
  &quot;scripts&quot;: {
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
    &quot;prepack&quot;: &quot;tsc&quot;
  },
  &quot;keywords&quot;: [],
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;devDependencies&quot;: {
    &quot;typescript&quot;: &quot;^4.0.3&quot;
  }
}"><pre class="notranslate"><span class="pl-ii">// https://github.com/kimamula/prepack-test/blob/master/package.json</span>
{
  <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>prepack-test<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1.0.0<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"description"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"main"</span>: <span class="pl-s"><span class="pl-pds">"</span>index.js<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"scripts"</span>: {
    <span class="pl-ent">"test"</span>: <span class="pl-s"><span class="pl-pds">"</span>echo <span class="pl-cce">\"</span>Error: no test specified<span class="pl-cce">\"</span> &amp;&amp; exit 1<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"prepack"</span>: <span class="pl-s"><span class="pl-pds">"</span>tsc<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"keywords"</span>: [],
  <span class="pl-ent">"author"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"license"</span>: <span class="pl-s"><span class="pl-pds">"</span>ISC<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>^4.0.3<span class="pl-pds">"</span></span>
  }
}</pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ npm install github:kimamula/prepack-test

changed 1 package, and audited 1 package in 6s

found 0 vulnerabilities"><pre class="notranslate">$ npm install github:kimamula/prepack-test

changed 1 package, and audited 1 package <span class="pl-k">in</span> 6s

found 0 vulnerabilities</pre></div>
<p dir="auto">-&gt; <code class="notranslate">tsc</code> should generate <code class="notranslate">index.js</code> file, but it's not generated.</p>
<h3 dir="auto">Environment:</h3>
<ul dir="auto">
<li>OS: macOS 10.15.6</li>
<li>Node: 12.18.3</li>
<li>npm: 7.0.0-beta.12</li>
</ul>