<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">This issue exists in the latest npm version</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I am using the latest npm</li>
</ul>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">This is a duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="802261813" data-permission-text="Title is private" data-url="https://github.com/npm/cli/issues/2632" data-hovercard-type="issue" data-hovercard-url="/npm/cli/issues/2632/hovercard" href="https://github.com/npm/cli/issues/2632">#2632</a>. This has been closed, but I still encounter it using the latest version of npm.</p>
<p dir="auto">When running <code class="notranslate">npm install</code> in a project that references a <code class="notranslate">bin</code> script that doesn’t exist, the command fails with the error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /home/remco/Projects/appsemble/node_modules/@appsemble/server/dist/index.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/remco/Projects/appsemble/node_modules/@appsemble/server/dist/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent"><pre class="notranslate"><code class="notranslate">npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /home/remco/Projects/appsemble/node_modules/@appsemble/server/dist/index.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/remco/Projects/appsemble/node_modules/@appsemble/server/dist/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
</code></pre></div>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto"><code class="notranslate">npm install</code> is succesful</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="git clone git@gitlab.com:appsemble/appsemble.git
cd appsemble
rm yarn.lock
npm install"><pre class="notranslate">git clone git@gitlab.com:appsemble/appsemble.git
<span class="pl-c1">cd</span> appsemble
rm yarn.lock
npm install</pre></div>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>npm: 8.5.5</li>
<li>Node.js: 16.14.2</li>
<li>OS Name: Pop!_OS</li>
<li>System Model Name:</li>
<li>npm config:</li>
</ul>
<div class="highlight highlight-source-ini notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="; &quot;global&quot; config from /home/remco/.local/etc/npmrc

fund = false 

; node bin location = /usr/bin/node
; cwd = /home/remco/Projects/appsemble
; HOME = /home/remco
; Run `npm config ls -l` to show all defaults"><pre class="notranslate"><span class="pl-c"><span class="pl-c">;</span> "global" config from /home/remco/.local/etc/npmrc</span>

<span class="pl-k">fund</span> = false 

<span class="pl-c"><span class="pl-c">;</span> node bin location = /usr/bin/node</span>
<span class="pl-c"><span class="pl-c">;</span> cwd = /home/remco/Projects/appsemble</span>
<span class="pl-c"><span class="pl-c">;</span> HOME = /home/remco</span>
<span class="pl-c"><span class="pl-c">;</span> Run `npm config ls -l` to show all defaults</span></pre></div>
<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">Currently all of our open source projects and many of our non-open source projects are unable to build because <code class="notranslate">npm</code> 7+ is reifying different file trees based on the publish event of an unrelated module. This meant that all of our builds that were working suddenly stopped working even though no dependencies changed on our side.</p>
<p dir="auto">Here's a reduced test case repo with detailed explanation and steps to repro: <a href="https://github.com/ryanblock/npm-time-based-dependency-graph">https://github.com/ryanblock/npm-time-based-dependency-graph</a></p>
<p dir="auto">Summary:</p>
<ul dir="auto">
<li>This project has two dependencies: <code class="notranslate">eslint@7</code> (which has many subdependencies) + <code class="notranslate">@architect/eslint-config</code>, which has 3 subdependencies:
<ul dir="auto">
<li><code class="notranslate">eslint-plugin-filenames</code></li>
<li><code class="notranslate">eslint-plugin-fp</code></li>
<li><code class="notranslate">eslint-plugin-import</code></li>
</ul>
</li>
<li>When deps before <code class="notranslate">2021-10-09T20:46:00.000Z</code> are installed:
<ul dir="auto">
<li>The 3 <code class="notranslate">eslint-plugin-$name</code> dependencies above are installed flatly into <code class="notranslate">node_modules/</code> (e.g. <code class="notranslate">node_modules/eslint-plugin/filenames</code>)</li>
</ul>
</li>
<li>When deps before <code class="notranslate">2021-10-09T20:47:00.000Z</code> are installed (one minute later):
<ul dir="auto">
<li>The 2 of 3 plugins are installed into <code class="notranslate">node_modules/@architect/eslint-config/node_modules/</code> (specifically <code class="notranslate">eslint-plugin-filenames</code>, <code class="notranslate">eslint-plugin-fp</code>)</li>
<li>The 3rd plugin is still installed flatly into <code class="notranslate">node_modules/</code></li>
</ul>
</li>
<li>eslint then runs, and cannot find <code class="notranslate">eslint-plugin-filenames</code> (nor <code class="notranslate">eslint-plugin-fp</code>, but it fails on the first plugin) because they are both installed in <code class="notranslate">node_modules/@architect/eslint-config/node_modules/</code>, away from the reach of Node's module resolution</li>
<li><strong>Note:</strong> <code class="notranslate">eslint@8</code> DOES NOT appear in this dependency tree anywhere, however it was published at <code class="notranslate">2021-10-09T20:46:13.874Z</code>
<ul dir="auto">
<li>This implies that Arborist / npm is reifying module locations based on the existence of a package that is not even in use in this project</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">No matter when <code class="notranslate">npm i</code> is run in a project with identical dependencies, the filesystem results should be the same.</p>
<h3 dir="auto">Steps To Reproduce</h3>
<p dir="auto">Steps to reproduce can be found at the following reduced test case repo: <a href="https://github.com/ryanblock/npm-time-based-dependency-graph">https://github.com/ryanblock/npm-time-based-dependency-graph</a></p>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>OS: macOS 11.6</li>
<li>Node: 16.10, 16.11</li>
<li>npm: 7, 8 (does not reproduce in npm 6)</li>
</ul>