Issue 1:
Is there an existing issue for this?

I have searched the existing issues

This issue exists in the latest npm version

I am using the latest npm

Current Behavior

This is a duplicate of #2632. This has been closed, but I still encounter it using the latest version of npm.

When running npm install in a project that references a bin script that doesn’t exist, the command fails with the error:

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

Expected Behavior

npm install is succesful

Steps To Reproduce

git clone git@gitlab.com:appsemble/appsemble.git
cd appsemble
rm yarn.lock
npm install

Environment

npm: 8.5.5

Node.js: 16.14.2

OS Name: Pop!_OS

System Model Name:

npm config:

; "global" 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

Issue 2:
Is there an existing issue for this?

I have searched the existing issues

Current Behavior

Currently all of our open source projects and many of our non-open source projects are unable to build because npm 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.

Here's a reduced test case repo with detailed explanation and steps to repro: https://github.com/ryanblock/npm-time-based-dependency-graph

Summary:

This project has two dependencies: eslint@7 (which has many subdependencies) + @architect/eslint-config, which has 3 subdependencies:

eslint-plugin-filenames

eslint-plugin-fp

eslint-plugin-import

When deps before 2021-10-09T20:46:00.000Z are installed:

The 3 eslint-plugin-$name dependencies above are installed flatly into node_modules/ (e.g. node_modules/eslint-plugin/filenames)

When deps before 2021-10-09T20:47:00.000Z are installed (one minute later):

The 2 of 3 plugins are installed into node_modules/@architect/eslint-config/node_modules/ (specifically eslint-plugin-filenames, eslint-plugin-fp)

The 3rd plugin is still installed flatly into node_modules/

eslint then runs, and cannot find eslint-plugin-filenames (nor eslint-plugin-fp, but it fails on the first plugin) because they are both installed in node_modules/@architect/eslint-config/node_modules/, away from the reach of Node's module resolution

Note: eslint@8 DOES NOT appear in this dependency tree anywhere, however it was published at 2021-10-09T20:46:13.874Z

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

Expected Behavior

No matter when npm i is run in a project with identical dependencies, the filesystem results should be the same.

Steps To Reproduce

Steps to reproduce can be found at the following reduced test case repo: https://github.com/ryanblock/npm-time-based-dependency-graph

Environment

OS: macOS 11.6

Node: 16.10, 16.11

npm: 7, 8 (does not reproduce in npm 6)