The review step runs `npm ci` inside an npm workspace package, silently deleting the rest of the monorepo's dependencies

Abierto Apto para principiantes
#1,633 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
tooling

Línea de trabajo

Empieza por la instrucción de reinstalación congelada en src/programs/posthog-integration/agent/review.md y luego lee la instalación específica de npm y el manejo de workspaces a los que hace referencia el issue. Comprueba cómo el paso de revisión elige su comando de instalación y si el npm ci --dry-run sugerido encaja en ese flujo. Se considera terminado cuando la comprobación de revisión de npm detecte discrepancias en el archivo de bloqueo sin eliminar dependencias de otros paquetes del workspace.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What happened

I ran the wizard (3.0.0) on an npm workspaces monorepo with --install-dir apps/web. The repo has one package-lock.json and one node_modules at the root, shared tools (typescript, @biomejs/biome, @playwright/test) as root devDependencies, and four workspace packages (apps/web, apps/server, apps/desktop, packages/shared).

During Verify and review the integration, the agent ran these from apps/web:

npm add posthog-js@1
npm ci                 # "npm's clean lockfile install check before compilation"
npm run build          # passed
npm run typecheck      # sh: tsc: command not found

Afterwards the root node_modules held only apps/web's dependency graph. typescript, @biomejs/biome, @playwright/test, electron and the other workspace links were gone. package-lock.json was unchanged, so git status showed nothing. Running npm install at the root restored everything.

The run summary said "verified a clean npm ci" and reported the typecheck as "unavailable because typescript is not declared in this package".

Why

src/programs/posthog-integration/agent/review.md asks for a frozen re-install after the last install:

https://github.com/PostHog/wizard/blob/f1cc489e38aae76e5e86a7b028861cdc9b284f5e/src/programs/posthog-integration/agent/review.md#L69-L72

After your last install, run the project's install once more without changing the lockfile (pnpm install --frozen-lockfile or its equivalent)

On npm the equivalent is npm ci, and with cd unavailable it runs in the workspace package. There npm scopes the command to that one package. npm ci deletes node_modules, then reinstalls only that package's dependencies. pnpm and yarn install the whole workspace from a sub-folder, so they don't have this problem.

The agent couldn't have worked around it:

  • The integration-build skill says to work only inside the project folder.
  • bash-fence.ts refuses directory flags that point outside it, so npm --prefix <root> ci isn't possible.
  • The agent's own detection ran from apps/web and saw a single-package repo, although the wizard's discovery had logged repoType=monorepo and detect_package_manager reported "the workspace lockfile is in ".
Minimal reproduction (npm 11.19.0, Node 24, macOS)
mkdir repro && cd repro && git init -q
cat > package.json <<'EOF'
{ "name": "repro", "private": true, "workspaces": ["apps/*"], "devDependencies": { "is-number": "7.0.0" } }
EOF
mkdir -p apps/web apps/api
echo '{ "name": "@repro/web", "version": "1.0.0", "private": true, "dependencies": { "ms": "2.1.3" } }' > apps/web/package.json
echo '{ "name": "@repro/api", "version": "1.0.0", "private": true, "dependencies": { "left-pad": "1.3.0" } }' > apps/api/package.json
npm install
ls node_modules                      # @repro  is-number  left-pad  ms
(cd apps/web && npm ci --dry-run)    # "up to date", nothing removed
(cd apps/web && npm ci)
ls node_modules                      # @repro  ms   <- is-number, left-pad and @repro/api are gone
Suggested fix

On npm, use npm ci --dry-run for the frozen re-check. It runs the same lockfile sync check as npm ci: when package.json and package-lock.json disagree, it fails with EUSAGE … Missing: <pkg> from lock file. It never deletes node_modules, it is safe from any workspace folder, and the bash fence already allows it.

It is weaker than a real npm ci in one way: a dry run downloads nothing and runs no install scripts, so a package whose download or install script would fail on a fresh install gets past it. On npm that gap is small: the npm add just before it had already downloaded the same packages and run their scripts. npm 11's allowScripts policy, its counterpart to pnpm's ignored build scripts, applies to that npm add as well, so a refused install script would show up there rather than in the dry run. Closing the gap would take a real npm ci from the workspace root. bash-fence.ts refuses directory flags outside the project folder, and that command would reinstall the whole monorepo.

 the project's install once more without changing the lockfile (`pnpm install
---frozen-lockfile` or its equivalent): if it fails on a package this run added, that package
+--frozen-lockfile`, `npm ci --dry-run` on npm,  or its equivalent): if it fails on a package this run added, that package
 does not fit.

Happy to test a fix against the same monorepo.

Lenguaje dominante
TypeScript
Estrellas
208
Forks
58
Merge medio
2 d 7 h
PR fusionados (30 d)
76

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PostHog/wizard

Todos los issues de PostHog/wizard

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.