Skip to content

[BUG] v7 erroneously reports removal of packages #3574

Open
@yo1dog

Description

@yo1dog

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

After installing aws-cdk package, subsequent npm commands such as install, prune, etc. always report "removed 7 packages" and the following lines:

npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/yallist
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/semver
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/lru-cache
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/yallist
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/semver
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/lru-cache
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/jsonschema

All of the above directories still exist after each command, so they are not actually deleted.

This bug appears to have been introduced in v7.0.0 as it occurs in v7.20.1, v7.0.0, but not in v6.14.13.

Expected Behavior

No packages were removed and npm should report as such.

Steps To Reproduce

mkdir v6
cd v6
npx npm@6 --version         # 6.14.13
npx npm@6 i aws-cdk@1.115.0 # added 181 packages from 216 contributors and audited 181 packages in 2.724s
stat node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/yallist # does not exist
npx npm@6 i --ddd           # audited 181 packages in 1.039s
stat node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/yallist # does not exist
npx npm@6 i --ddd           # audited 181 packages in 0.944s
npx npm@6 prune -ddd        # audited 181 packages in 0.897s
npx npm@6 prune -ddd        # audited 181 packages in 1.008s

cd ..
mkdir v7
cd v7
npx npm@7 i --version       # 7.20.1
npx npm@7 i aws-cdk@1.115.0 # added 181 packages, and audited 182 packages in 2s
stat node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/yallist # exists
npx npm@7 i --ddd           # removed 7 packages, and audited 182 packages in 734ms
stat node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/yallist # exists
npx npm@7 i --ddd           # removed 7 packages, and audited 182 packages in 728ms
npx npm@7 prune --ddd       # removed 7 packages, and audited 182 packages in 699ms
npx npm@7 prune --ddd       # removed 7 packages, and audited 182 packages in 1s

Notice the output for all but the first npm commands report "removed 7 packages" for v7 but not for v6. Also, the following lines:

npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/yallist
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/semver
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cx-api/node_modules/lru-cache
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/yallist
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/semver
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/lru-cache
npm sill REMOVE node_modules/aws-cdk/node_modules/@aws-cdk/cloud-assembly-schema/node_modules/jsonschema

Notice these reported directories were never created in v6, and in v7 they are never deleted (still exist every v7 npm command) despite being reported as "REMOVE".

Attached the output for the first 3 install commands and the package files for v7:
1.log
2.log
3.log
package.json.txt
package-lock.json.txt

Environment

  • OS: Ubuntu 18.04.3 LTS (WSL2)
  • Node: v14.17.0
  • npm: 7.20.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions