From e3f34a264f3601ab8bfb66250356ad2cb533457c Mon Sep 17 00:00:00 2001 From: ethenotethan <42627790+ethenotethan@users.noreply.github.com> Date: Mon, 23 Feb 2026 02:42:00 +0700 Subject: [PATCH] feat: add strict Node.js version compatibility checks Add preflight Node.js version validation (>=18) in CLI entry points (bin/run.js, bin/dev.js) before loading dependencies, and declare engines field in both cli and sdk package.json files. Co-Authored-By: Claude Opus 4.6 --- packages/cli/bin/dev.js | 14 +++++++++++++- packages/cli/bin/run.js | 17 ++++++++++++++++- packages/cli/package.json | 3 +++ packages/sdk/package.json | 3 +++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/cli/bin/dev.js b/packages/cli/bin/dev.js index 0e01a062..90c22569 100755 --- a/packages/cli/bin/dev.js +++ b/packages/cli/bin/dev.js @@ -1,5 +1,17 @@ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning -import { execute } from "@oclif/core"; +const MIN_NODE_MAJOR = 18; +const currentVersion = process.versions.node; +const currentMajor = parseInt(currentVersion.split(".")[0], 10); + +if (currentMajor < MIN_NODE_MAJOR) { + console.error( + `\nError: ecloud requires Node.js v${MIN_NODE_MAJOR} or later, but you are running v${currentVersion}.\n` + + `Please upgrade Node.js: https://nodejs.org/\n`, + ); + process.exit(1); +} + +const { execute } = await import("@oclif/core"); await execute({ development: true, dir: import.meta.url }); diff --git a/packages/cli/bin/run.js b/packages/cli/bin/run.js index 94a0d6f8..90e7b769 100755 --- a/packages/cli/bin/run.js +++ b/packages/cli/bin/run.js @@ -1,5 +1,20 @@ #!/usr/bin/env node -import { execute } from "@oclif/core"; +// Preflight: check Node.js version before loading dependencies. +// Without this, an incompatible Node version surfaces as a cryptic +// "ReferenceError: crypto is not defined" deep in the workflow. +const MIN_NODE_MAJOR = 18; +const currentVersion = process.versions.node; +const currentMajor = parseInt(currentVersion.split(".")[0], 10); + +if (currentMajor < MIN_NODE_MAJOR) { + console.error( + `\nError: ecloud requires Node.js v${MIN_NODE_MAJOR} or later, but you are running v${currentVersion}.\n` + + `Please upgrade Node.js: https://nodejs.org/\n`, + ); + process.exit(1); +} + +const { execute } = await import("@oclif/core"); await execute({ dir: import.meta.url }); diff --git a/packages/cli/package.json b/packages/cli/package.json index c8ab880d..5f714971 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -2,6 +2,9 @@ "name": "@layr-labs/ecloud-cli", "version": "0.0.0-development", "type": "module", + "engines": { + "node": ">=18.0.0" + }, "files": [ "dist", "bin", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 8d73975c..d718a579 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -2,6 +2,9 @@ "name": "@layr-labs/ecloud-sdk", "version": "0.0.0-development", "type": "module", + "engines": { + "node": ">=18.0.0" + }, "main": "dist/index.js", "module": "dist/index.js", "types": "dist/index.d.ts",