[BUG] bundleDependencies are not installed from a git dependency when the cache path contains a symlink

Aperta
#10,250 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
backend, cli

Direzione di ricerca

The reproduction compares installing the same commit from an npm pack tarball and a git dependency; start by tracing npm CLI's git dependency install and bundleDependencies handling. Use the provided steps with a package that also declares a registry dependency such as ms, then compare the installed node_modules contents. Done means git installs retain the bundled dep as the tarball install does.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:git-dependencies Bug Priority 3
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

A package commits a bundled dependency (node_modules/dep, listed in bundleDependencies) and also has a regular registry dependency (ms). Installing the package's tarball keeps the bundled dependency. Installing the same commit as a git dependency does not: node_modules/pkg/node_modules does not exist, although the install reports success.

--- install from tarball
dep
--- install from git (same commit)
ls: node_modules/pkg/node_modules: No such file or directory

The registry dependency is the trigger. With "dependencies": { "dep": "1.0.0" } only (no ms), the git install keeps the bundled dep. Scoped bundled names behave the same as unscoped ones.

The tarball in the reproduction is npm pack output of the same commit and contains the bundle, so the bundle is lost during the git install, not when packing.

Expected Behavior

Installing from git installs the bundled dependency, as installing the tarball of the same commit does.

Steps To Reproduce
set -e
rm -rf work-bundle && mkdir work-bundle && cd work-bundle
ROOT=$PWD

# pkg bundles dep: node_modules/dep is committed and listed in bundleDependencies
git init -q pkg && cd pkg
git config user.email a@b && git config user.name a
echo '{"name":"pkg","version":"1.0.0","dependencies":{"dep":"1.0.0","ms":"^2.1.3"},"bundleDependencies":["dep"]}' > package.json
mkdir -p node_modules/dep
echo '{"name":"dep","version":"1.0.0"}' > node_modules/dep/package.json
git add -f . && git commit -qm init && SHA=$(git rev-parse HEAD)
npm pack --pack-destination "$ROOT" >/dev/null 2>&1
cd "$ROOT"

echo '--- install from tarball'
mkdir from-tarball && cd from-tarball && echo '{"private":true}' > package.json
npm install --no-audit --no-fund "$ROOT/pkg-1.0.0.tgz" >/dev/null
ls node_modules/pkg/node_modules
cd "$ROOT"

echo '--- install from git (same commit)'
mkdir from-git && cd from-git && echo '{"private":true}' > package.json
npm install --allow-git=all --no-audit --no-fund "git+file://$ROOT/pkg#$SHA" >/dev/null
ls node_modules/pkg/node_modules 2>&1 || true
Environment
  • npm: 12.2.2 (also reproduced with 11.11.0)
  • Node.js: 26.13.0
  • OS Name: macOS
  • System Model Name: Mac
  • npm config:
; default config
Lingua principale
JavaScript
Stelle
10.3k
Fork
5k
Merge medio
4g 11h
PR unite (30g)
26

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/cli

Tutte le issue di npm/cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.