<h1 dir="auto">What / Why</h1>
<p dir="auto">Executing <code class="notranslate">npm ci</code> ignores the <code class="notranslate">os</code> field in package.json. This causes platform specific packages like <code class="notranslate">fsevents</code> (macOS-only) to be installed on other platforms (Windows in this case).</p>
<h2 dir="auto">When</h2>

<ul dir="auto">
<li>Every install through <code class="notranslate">npm ci</code></li>
</ul>
<h2 dir="auto">Where</h2>

<ul dir="auto">
<li>Packages with the <code class="notranslate">os</code> field specified in package.json</li>
</ul>
<h2 dir="auto">How</h2>
<h3 dir="auto">Current Behavior</h3>

<ul dir="auto">
<li>See description</li>
</ul>
<h3 dir="auto">Steps to Reproduce</h3>

<ol dir="auto">
<li>Run npm init in a new directory on a windows machine</li>
<li>Install a package with a deeply nested optional dependency on fsevents, like webpack: <code class="notranslate">npm i webpack</code></li>
<li>Notice a package-lock.json is created with an optional dependency on <code class="notranslate">fsevents@1.2.11</code></li>
<li>Remove <code class="notranslate">node_modules</code> te create a clean CI clone state</li>
<li>Run <code class="notranslate">npm ci</code></li>
<li>See the installation fail because <code class="notranslate">fsevents</code> is downloaded, installed, and node-gyp is executed as a result.</li>
</ol>
<h3 dir="auto">Expected Behavior</h3>

<ul dir="auto">
<li><code class="notranslate">fsevents</code> is skipped as the package is unsupported on Windows.</li>
</ul>
<h2 dir="auto">Who</h2>

<ul dir="auto">
<li><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pipobscure/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pipobscure">@pipobscure</a></li>
<li><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/paulmillr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/paulmillr">@paulmillr</a></li>
</ul>
<h2 dir="auto">References</h2>

<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="541086502" data-permission-text="Title is private" data-url="https://github.com/fsevents/fsevents/issues/301" data-hovercard-type="issue" data-hovercard-url="/fsevents/fsevents/issues/301/hovercard" href="https://github.com/fsevents/fsevents/issues/301">fsevents/fsevents#301</a></li>
</ul>
<h1 dir="auto">What / Why</h1>
<p dir="auto">npm ci seems to install an optional dependency for the linux os when running on a mac and seems to install the optional dependency for mac when running on linux.</p>
<h2 dir="auto">When</h2>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ npm init -y; npm i oax@0.5.25; npm ls; npm ci; npm ls"><pre class="notranslate">$ npm init -y<span class="pl-k">;</span> npm i oax@0.5.25<span class="pl-k">;</span> npm ls<span class="pl-k">;</span> npm ci<span class="pl-k">;</span> npm ls</pre></div>
<details>
<summary>click to view output of above command</summary>
<pre class="notranslate">Wrote to /private/tmp/d/package.json:
<p dir="auto">{<br>
"name": "d",<br>
"version": "1.0.0",<br>
"description": "",<br>
"main": "index.js",<br>
"scripts": {<br>
"test": "echo "Error: no test specified" &amp;&amp; exit 1"<br>
},<br>
"keywords": [],<br>
"author": "",<br>
"license": "ISC"<br>
}</p>
<blockquote>
<p dir="auto">oax@0.5.25 postinstall /private/tmp/d/node_modules/oax<br>
node ./postinstall.js</p>
</blockquote>
<p dir="auto">npm notice created a lockfile as package-lock.json. You should commit this file.<br>
npm WARN d@1.0.0 No description<br>
npm WARN d@1.0.0 No repository field.<br>
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: oax-windows-64@0.5.25 (node_modules/oax/node_modules/oax-windows-64):<br>
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for oax-windows-64@0.5.25: wanted {"os":"win32","arch":"x64"} (current: {"os":"darwin","arch":"x64"})<br>
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: oax-linux-64@0.5.25 (node_modules/oax/node_modules/oax-linux-64):<br>
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for oax-linux-64@0.5.25: wanted {"os":"linux","arch":"x64"} (current: {"os":"darwin","arch":"x64"})</p>
<ul dir="auto">
<li>oax@0.5.25<br>
added 2 packages and audited 4 packages in 1.1s<br>
found 0 vulnerabilities</li>
</ul>
<p dir="auto">d@1.0.0 /private/tmp/d<br>
└─┬ oax@0.5.25<br>
├── oax-darwin@0.5.25<br>
├── UNMET OPTIONAL DEPENDENCY oax-linux-64@0.5.25<br>
└── UNMET OPTIONAL DEPENDENCY oax-windows-64@0.5.25</p>
<p dir="auto">npm WARN prepare removing existing node_modules/ before installation</p>
<blockquote>
<p dir="auto">oax@0.5.25 postinstall /private/tmp/d/node_modules/oax<br>
node ./postinstall.js</p>
</blockquote>
<p dir="auto">added 3 packages in 0.722s<br>
d@1.0.0 /private/tmp/d<br>
└─┬ oax@0.5.25<br>
├── oax-darwin@0.5.25<br>
├── oax-linux-64@0.5.25<br>
└── UNMET OPTIONAL DEPENDENCY oax-windows-64@0.5.25<br>
</p></pre><p dir="auto"></p>
</details>
<h2 dir="auto">Where</h2>
<ul dir="auto">
<li>n/a</li>
</ul>
<h2 dir="auto">How</h2>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">currently it looks like npm ci is broken for optional dependencies which use the os and arch fields of package.json</p>
<h3 dir="auto">Steps to Reproduce</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ npm init -y; npm i oax@0.5.25; npm ls; npm ci; npm ls"><pre class="notranslate">$ npm init -y<span class="pl-k">;</span> npm i oax@0.5.25<span class="pl-k">;</span> npm ls<span class="pl-k">;</span> npm ci<span class="pl-k">;</span> npm ls</pre></div>
<p dir="auto">You should see that <code class="notranslate">npm i</code> works correctly and installs a single optional dependency for oax.<br>
You should also see that <code class="notranslate">npm ci</code> works incorrectly and installs two of the optional dependencies for oax, this should never happen as each optional dependency is targeting a different operating system and architecture, it should be impossible to have more than one of the optional dependencies installed.</p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">it should install oax-darwin when running on darwin and should install oax-linux when running on linux</p>
<h2 dir="auto">Who</h2>
<ul dir="auto">
<li>n/a</li>
</ul>
<h2 dir="auto">References</h2>
<ul dir="auto">
<li>n/a</li>
</ul>