-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 -g
removes some globally installed packages
#2620
Comments
What are you expecting to happen with a global dedupe? (certainly not remove packages, this sounds like a bug) |
I'd expect the same behaviour as npm v6 where each top-level globally installed package persists after the global dedupe. In the example I've given I'd expect all 12 globally installed packages to still be installed after the dedupe. |
Right, but i mean, what do you expect it to change - to deduplicate? |
oh, I see what you're asking. From the documentation this is:
|
That's not what dedupe does tho - it hoists everything farther up the filesystem so they can be shared. However, in the case of global packages, nothing can be hoisted up to the global root (or it'd mess with In other words, I'd expect |
That's what I meant, even if I didn't explain it very clearly or gave a duff example. Here's a better (real world) example. I install If I look on my linux system (where I don't see this problem) and examine the output of
I think we can agree that |
Agreed. I think the correct behavior would be to error immediately with a message that deduping global packages doesn’t make sense. |
this is fixed in npm 7.5.5 (we now throw an error to prevent you from doing something that won't work how you expect anyway) |
Current Behaviour:
I have some npm packages installed globally, which are command line utilities (
create-react-app
,distributed-dig
, snyk`, and others). I recently updated to npm version 7 (7.5.2) with node 14 (14.15.4) on Windows 10 (version: 2004 || build: 19041.746).If I perform a global
dedupe
...... a number of the globally installed packages are removed. Curiously not all of them. In the example below eight of the 11 are removed.
Incidentally, I couldn't reproduce this behaviour with npm v7.5.2 & node v15.5.1 on Linux Mint v19
Expected Behaviour:
I'd expect the same behaviour as npm v6 where each top-level globally installed package persists after the global dedupe. In the example steps below I'd expect all 11 globally installed packages to still be installed after the dedupe.
Steps To Reproduce:
Report current versions:
npm -v ; node -v
List currently installed global packages (and report a count):
npm ls -g --depth 0;npm ls -g --depth 0|find
"--" /c
Perform a global dedupe:
npm dedupe -g
Notice that
removed 1334 packages
Re-list globally installed packages (and a new count):
npm ls -g --depth 0;npm ls -g --depth 0|find
"--" /c
Eight of the the initial 11 global packages are now removed
Environment:
cmd.exe
instead:The text was updated successfully, but these errors were encountered: