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 7.5.x is deleting all packages when one package is updated (global) #2736

Closed
JoeUX opened this issue Feb 19, 2021 · 2 comments
Closed
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@JoeUX
Copy link

JoeUX commented Feb 19, 2021

Current Behavior:

All my global packages are being deleted when I run an npm update -g ... command, except for the package that I'm updating. This has been happening for at least a month. Currently it's happening with npm 7.5.4, but I think it was also happening with earlier 7.5.x releases. See the screenshot below.

Expected Behavior:

It should just update the specified package. It should not delete any packages.

Steps To Reproduce:

  1. Start with Node 14.15.5 (LTS) on Windows 10 Pro 64-bit.
  2. Install the latest npm globally with npm install -g npm@latest. Currently this installs npm 7.5.4.
  3. Install a bunch of packages globally with npm install -g ....
  4. Wait a few days for updates to some packages to become available. Check with npm -g outdated.
  5. Update a package, e.g. npm update -g eslint.
  6. List your installed packages with npm ls -g --depth=0.
  7. They're all gone except for the one you just updated (in this case eslint).
  8. Check C:\Users\Joe\AppData\Roaming\npm\node_modules. All module folders are gone, except for the package you just updated.
  9. Check npm version with npm -g -v. It says npm 6.14.10, probably the version that shipped with Node 14.15.5. npm deleted itself too, at least the updated version.

Screenshot captures everything:

npm deletion bug

Environment:

  • OS: Windows 10 Pro 64-bit 20H2
  • Node: 14.15.5
  • npm: 7.5.4
@JoeUX JoeUX 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 Feb 19, 2021
@ljharb
Copy link
Contributor

ljharb commented Feb 19, 2021

to update a global eslint, you'd run npm install -g eslint - there's no global lockfile, so npm update doesn't do anything for you there.

that said, there shouldn't ever be any auto-pruning on npm root -g, and this does seem like a bug.

@nlf nlf added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Feb 22, 2021
@isaacs isaacs closed this as completed in 9b311fe Feb 22, 2021
@greg-hornby-roam
Copy link

This happened to me on version 8.1

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 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

4 participants