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] npm dedupe after npm update removes everything in package.json & package-lock.json and changes package name to "dedupe" #1693

Closed
kokarn opened this issue Aug 19, 2020 · 2 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@kokarn
Copy link

kokarn commented Aug 19, 2020

Current Behavior:

Empties everything except name from package.json & package-lock.json

$ npm dedupe
removed 1925 packages in 28s

package.json

{
  "name": "dedupe"
}

Expected Behavior:

Dedupe should dedupe, maybe with smaller changes?

Steps To Reproduce:

Pretty basic react app with the following package.json

{
  "name": "dedupe-test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "got": "^11.5.1",
    "history": "^5.0.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^3.4.1",
    "victory": "^35.0.8"
  },
  "scripts": {
    "ci-test": "echo \"works\""
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "husky": "^4.2.5"
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run ci-test",
      "pre-push": "npm run ci-test"
    }
  }
}
  1. npm install
  2. npm update
  3. npm dedupe

Environment:

  • OS: macOS 10.15.6
  • Node: 14.7.0
  • NPM: 7 beta 5
@kokarn kokarn added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Aug 19, 2020
@kokarn kokarn changed the title [BUG] npm dedupe after npm update removes everything in package.json & package-lock.json [BUG] npm dedupe after npm update removes everything in package.json & package-lock.json and changes project name to "dedupe" Aug 19, 2020
@kokarn kokarn changed the title [BUG] npm dedupe after npm update removes everything in package.json & package-lock.json and changes project name to "dedupe" [BUG] npm dedupe after npm update removes everything in package.json & package-lock.json and changes package name to "dedupe" Aug 19, 2020
@isaacs
Copy link
Contributor

isaacs commented Aug 20, 2020

Same root cause as #1690. Will be fixed in next update.

isaacs added a commit that referenced this issue Aug 20, 2020
- Load root project `package.json` when running loadVirtual.
  Fix: #1690
  Fix: #1693

- Fetch metadata from registry when loading tree from outdated
  package-lock.json file.  This avoids a situation where a lockfile or
  shrinkwrap from npm v5 would result in deleting dependencies on
  install.

- Preserve `package.json` and `package-lock.json` formatting in all
  places where these files are written.
  Fix: #1662
@isaacs
Copy link
Contributor

isaacs commented Aug 23, 2020

Fixed in latest v7 beta. Thanks!

@isaacs isaacs closed this as completed Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

2 participants