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 update -g package@latest removes all global packages #3175

Closed
mukaschultze opened this issue May 1, 2021 · 4 comments
Closed

[BUG] npm update -g package@latest removes all global packages #3175

mukaschultze opened this issue May 1, 2021 · 4 comments
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@mukaschultze
Copy link

mukaschultze commented May 1, 2021

Current Behavior:

Attempting to update a package with a tag using the update command globally causes ALL global packages to be removed.

Expected Behavior:

Packages should not be removed when updating global packages.

Steps To Reproduce:

npm i -g typescript nodemon @angular/cli # Install some global packages
npm ls -g --depth=0 # This shows the 3 installed packages
npm update -g @angular/cli@latest # Attempt to update one of the packages with a @latest tag
# Oh no! removed 620 packages
npm ls -g --depth=0 # Shows `-- (empty)

Environment:

  • OS: Windows 10 20H2
  • Node: 15.9.0
  • npm: 7.11.2

Additional Info

This only happens on the global scope

@mukaschultze mukaschultze 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 May 1, 2021
@wraithgar
Copy link
Member

Likely related: #3159

@darcyclarke darcyclarke added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Jun 11, 2021
@darcyclarke darcyclarke removed this from the OSS - Sprint 35 milestone Aug 23, 2021
@famzah
Copy link

famzah commented Sep 6, 2021

I am astonished that this hasn't been fixed for months! NPM just removed all my global packages.

A workaround is to use install instead of update.

@rodnikovdev
Copy link

Just faced the same issue with npm update -g npx. All symlinks inside bin/ removed and lib/node_modules is empty.

Environment:

  • OS: Xubuntu 20.04
  • Node: 16.13.1
  • npm: 8.1.2 (same issue for 8.3.0)

@mnapoli
Copy link

mnapoli commented Jan 18, 2022

I reported and closed #4240 as duplicate of this issue. Note that it seems to be the @ that causes issues, not specifically @latest.

I can reproduce it with any version number (all dependencies get wiped out anyway). I also reproduce it with NPM v8.

mnapoli added a commit to serverless/serverless that referenced this issue Jan 18, 2022
mnapoli added a commit to serverless/serverless that referenced this issue Jan 18, 2022
ruyadorno added a commit to ruyadorno/cli that referenced this issue Jan 21, 2022
Arborist was not loading the actual tree when using named updates for
global updates, that would result in removing all previously installed
deps from a global install anytime the user would try to run
`npm update <pkgname>`.

This changeset fixes the problem by allowing the load of the actual tree
if the `global` and `update.names` options are defined.

Added a few more tests to illustrate but some of the snapshots already
included were actually demonstrating the problem by having empty trees
as result, these are now also updated with the expected tree result.

Fixes: npm#3175
mnapoli added a commit to serverless/serverless that referenced this issue Jan 25, 2022
mnapoli added a commit to serverless/serverless that referenced this issue Jan 25, 2022
mnapoli added a commit to serverless/serverless that referenced this issue Jan 25, 2022
mnapoli added a commit to serverless/serverless that referenced this issue Jan 25, 2022
medikoo pushed a commit to serverless/serverless that referenced this issue Jan 25, 2022
medikoo pushed a commit to serverless/serverless that referenced this issue Jan 27, 2022
medikoo pushed a commit to serverless/serverless that referenced this issue Jan 27, 2022
medikoo pushed a commit to serverless/serverless that referenced this issue Jan 27, 2022
rm-hull pushed a commit to rm-hull/serverless that referenced this issue Jan 28, 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 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

7 participants