Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] package-lock is not cleaned up completely when workspace is removed #5463

Open
2 tasks done
gribnoysup opened this issue Sep 2, 2022 · 0 comments · May be fixed by #5478
Open
2 tasks done

[BUG] package-lock is not cleaned up completely when workspace is removed #5463

gribnoysup opened this issue Sep 2, 2022 · 0 comments · May be fixed by #5478
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@gribnoysup
Copy link

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

After removing workspace from project and updating package-lock with npm install, some references to the removed workspace still exist

Expected Behavior

All references of the removed package are removed from package-lock

Steps To Reproduce

  1. Create a basic npm workspace
mkdir new-project
cd new-project
npm init -y
npm init -y -w ./packages/a
npm init -y -w ./packages/b
  1. Check package-lock file
{
  "name": "npm-workspace-remove",
  "version": "1.0.0",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-workspace-remove",
      "version": "1.0.0",
      "license": "ISC",
      "workspaces": [
        "packages/a",
        "packages/b"
      ]
    },
    "node_modules/a": {
      "resolved": "packages/a",
      "link": true
    },
    "node_modules/b": {
      "resolved": "packages/b",
      "link": true
    },
    "packages/a": {
      "version": "1.0.0",
      "license": "ISC"
    },
    "packages/b": {
      "version": "1.0.0",
      "license": "ISC",
      "devDependencies": {}
    }
  },
  "dependencies": {
    "a": {
      "version": "file:packages/a"
    },
    "b": {
      "version": "file:packages/b"
    }
  }
}
  1. Remove one of the workspaces
rm -rf packages/b
  1. Update the lock file with npm install and check the package-lock again
{
  "name": "npm-workspace-remove",
  "version": "1.0.0",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-workspace-remove",
      "version": "1.0.0",
      "license": "ISC",
      "workspaces": [
        "packages/a"
      ]
    },
    "node_modules/a": {
      "resolved": "packages/a",
      "link": true
    },
    "packages/a": {
      "version": "1.0.0",
      "license": "ISC"
    },
    "packages/b": {
      "version": "1.0.0",
      "extraneous": true,
      "license": "ISC",
      "devDependencies": {}
    }
  },
  "dependencies": {
    "a": {
      "version": "file:packages/a"
    }
  }
}

You can see that "packages/b" part is still there

Environment

  • npm: 8.19.1
  • Node.js: v16.15.1
  • OS Name: macOS Monterey 12.5.1
  • System Model Name: Macbook Pro
  • npm config:
; "user" config from /Users/sergey.petushkov/.npmrc

//localhost:4873/:_authToken = (protected)
//registry.npmjs.org/:_authToken = (protected)

; node bin location = /Users/sergey.petushkov/.nvm/versions/node/v16.15.1/bin/node
; node version = v16.15.1
; npm local prefix = /Users/sergey.petushkov/Projects/MongoDB/npm-workspace-remove
; npm version = 8.19.1
; cwd = /Users/sergey.petushkov/Projects/MongoDB/npm-workspace-remove
; HOME = /Users/sergey.petushkov
; Run `npm config ls -l` to show all defaults.
@gribnoysup gribnoysup added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Sep 2, 2022
@lukekarrys lukekarrys added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Sep 2, 2022
sun0day pushed a commit to sun0day/cli that referenced this issue Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants