Skip to content

[BUG] Removed modules left behind in package-lock.json if they were installed from a local folder #3141

Description

@Malvineous

Current Behavior:

Running npm install ../localpkg && rpm remove localpkg results in entries for ../localpkg being left behind in package-lock.json even though the module has been completely removed.

Expected Behavior:

In NPM 6.x (and in 7.x for non-local packages), their entries are removed from package-lock.json when a package is removed. This behaviour should also apply to packages installed from a local folder.

Steps To Reproduce:

  1. git stash (to start with a clean repo)
  2. npm install ../some-package
  3. npm remove ../some-package
  4. git diff package-lock.json
  5. Observe there are now new entries in package-lock.json for ../some-package even though it was removed.

My use case is that for local development, I am removing a module from my project and installing a local version of it for development, so that I can work on both my code and the module code concurrently. When I am ready to deploy, I then remove the local version and install the published version. However while this used to work fine with NPM 6.x, since upgrading to 7.x it now always leaves behind unwanted entries in package-lock.json for the version in the local folder I was using temporarily.

I am currently using either git or a text editor to remove these extra entries from package-lock.json. Running npm install does not put them back or complain, confirming that they are unnecessary, so it would be nice if npm took care of this automatically like it did in 6.x.

Environment:

  • OS: Arch Linux
  • Node: 15.14.0
  • npm: 7.9.0 and 7.10.0

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