From a229e8e77b36082bb455909bd8505fff04080bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Magyar?= Date: Mon, 25 May 2026 15:31:11 +0100 Subject: [PATCH] fix(build): skip build.js when running outside the monorepo (#1795) (#1816) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `scripts/build.js` assumes the monorepo sibling `gitnexus-shared` exists. When a user runs `npm install` from within a global install directory, the `prepare` lifecycle fires `build.js`, which calls `execSync(tsc, { cwd: nonExistentPath })` — Node reports this as the misleading `spawnSync /bin/sh ENOENT`. Add an early guard: if `gitnexus-shared` is absent and `dist/` already exists (published package context), exit cleanly. If neither exists, print a helpful error pointing to the monorepo checkout. Co-authored-by: Test --- gitnexus/scripts/build.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gitnexus/scripts/build.js b/gitnexus/scripts/build.js index e651708e3..044fc36ee 100644 --- a/gitnexus/scripts/build.js +++ b/gitnexus/scripts/build.js @@ -35,6 +35,22 @@ function getBuildTimeoutMs() { const BUILD_TIMEOUT_MS = getBuildTimeoutMs(); +// Published-package guard: when installed from the npm registry the +// monorepo sibling `gitnexus-shared` does not exist and `dist/` is +// already pre-built. Skip the build to avoid a misleading ENOENT +// crash (#1795). +if (!fs.existsSync(SHARED_ROOT)) { + if (fs.existsSync(DIST)) { + console.log('[build] skipping — dist/ already present (published package).'); + process.exit(0); + } + console.error( + `[build] gitnexus-shared not found at ${SHARED_ROOT} and no dist/ exists.\n` + + 'Are you running from the monorepo checkout? Run `npm install` from the repo root first.', + ); + process.exit(1); +} + // ── 1. Build gitnexus-shared ─────────────────────────────────────── console.log('[build] compiling gitnexus-shared…'); const tscCmd =