[BUG] install-strategy=linked never reports removed packages: --dry-run shows nothing, --json says removed: 0, and the root `dependencies` script is skipped
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, nodejs
- Ambito
- devtools
Direzione di ricerca
Start in workspaces/arborist/lib/arborist/reify.js, at #buildLinkedActualForDiff and #cleanOrphanedStoreEntries, to see why the linked-strategy diff never contains a REMOVE and why cleanup is skipped on dry runs. Reproduce with the steps in the issue, comparing hoisted and linked output for npm uninstall and --json. Done when linked reports the removed count in summary, dry-run and JSON, and the root dependencies script runs on removal.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
With install-strategy=linked, npm never reports the packages it removes. Compared with the default (hoisted) strategy, using the same project:
| Command | hoisted | linked |
|---|---|---|
npm uninstall e (removes 4 packages) |
removed 4 packages | up to date |
npm uninstall e --dry-run |
removed 4 packages | up to date (then the real run removes 4) |
npm prune --dry-run |
lists remove b, remove a |
up to date (then the real npm prune removes them) |
npm uninstall e --json |
"removed": 4 |
"removed": 0 |
root dependencies lifecycle script on uninstall |
runs | does not run |
So under linked, a dry run tells you nothing will change and then the real command removes packages, tooling that reads the --json counts sees zeros, and the documented dependencies script ("run after any operations that modify the node_modules directory IF changes occurred") is skipped.
The packages are removed correctly on disk; only the reporting is wrong.
Cause: #buildLinkedActualForDiff in workspaces/arborist/lib/arborist/reify.js builds the actual side of the linked diff only from ideal-tree children, so the diff never contains a REMOVE. #cleanOrphanedStoreEntries deletes the removed packages after the diff, but doesn't report them, and it's skipped entirely on --dry-run. reify-output and the dependencies script both rely on the diff.
Expected Behavior
Removals under install-strategy=linked are reported like under the default strategy: in the summary, in --dry-run (without removing anything), and in --json. The root dependencies script runs when packages are removed.
Steps To Reproduce
Any registry package with a dependency works; for example:
mkdir linked-repro && cd linked-repro && npm init -y
npm install --install-strategy=linked which@4
npm uninstall which --install-strategy=linked --dry-run # up to date
npm uninstall which --install-strategy=linked --json # "removed": 0
Compare with --install-strategy=hoisted, which reports removed 2 packages in both cases.
For the lifecycle script, add "scripts": { "dependencies": "node -e \"console.log('dependencies ran')\"" } to package.json and run npm install and then npm uninstall with each strategy (add --foreground-scripts to see the output).
Environment
- npm: 12.2.3 (
latestbranch) - Node.js: 24.20.0
- OS Name: Windows 11 (the cause is platform-independent)
- Lingua principale
- JavaScript
- Stelle
- 10.3k
- Fork
- 5k
- Merge medio
- 4g 11h
- PR unite (30g)
- 26
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/cli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsForse già presa @saruk-vedant l’ha presa 7 giorni fa. ApertaBug Needs Triage Triage Requested
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyForse già presa @drawliin l’ha presa 42 giorni fa. Apertacmd:delete Priority 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 2 giorni
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaEngineering Priority 1
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 2 giorni
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysForse già presa @greenlincoln05 l’ha presa 63 giorni fa. ApertaPriority 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
Issue simili
-
docs: add SECURITY.md vulnerability reporting policyForse già presa @AK-Lmn l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
flisk-sh/linux2wasm#12 ·
I maintainer di solito rispondono entro 1 giorno
-
possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Mintplex-Labs/anything-llm#7388 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
v6: Minified bootstrap.min.css is missing header infoForse già presa @lazerg l’ha presa oggi. Apertabug build confirmed has-pr v6
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
githubnext/gh-aw-workshop#6332 ·
I maintainer di solito rispondono entro 1 giorno