From 0fa2e8ca85005362d9043d82469f3c3525f4c4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 21 Oct 2024 17:41:56 +0200 Subject: [PATCH] fix(core): Enforce nodejs version consistently (#11323) --- packages/cli/bin/n8n | 29 ++++++++++++++--------------- packages/cli/package.json | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/cli/bin/n8n b/packages/cli/bin/n8n index c4b593ccc9291..c3355767afea3 100755 --- a/packages/cli/bin/n8n +++ b/packages/cli/bin/n8n @@ -18,21 +18,20 @@ if (process.argv.length === 2) { process.argv.push('start'); } -const nodeVersion = process.versions.node; -const { major, gte } = require('semver'); - -const MINIMUM_SUPPORTED_NODE_VERSION = '18.17.0'; -const ENFORCE_MIN_NODE_VERSION = process.env.E2E_TESTS !== 'true'; - -if ( - (ENFORCE_MIN_NODE_VERSION && !gte(nodeVersion, MINIMUM_SUPPORTED_NODE_VERSION)) || - ![18, 20, 22].includes(major(nodeVersion)) -) { - console.log(` - Your Node.js version ${nodeVersion} is currently not supported by n8n. - Please use Node.js v${MINIMUM_SUPPORTED_NODE_VERSION} (recommended), v20, or v22 instead! - `); - process.exit(1); +const ENFORCE_NODE_VERSION_RANGE = process.env.E2E_TESTS !== 'true'; +if (ENFORCE_NODE_VERSION_RANGE) { + const satisfies = require('semver/functions/satisfies'); + const nodeVersion = process.versions.node; + const { + engines: { node: supportedNodeVersions }, + } = require('../package.json'); + if (!satisfies(nodeVersion, supportedNodeVersions)) { + console.error(` +Your Node.js version ${nodeVersion} is currently not supported by n8n. +Please use a Node.js version that satisfies the following version range: ${supportedNodeVersions} +`); + process.exit(1); + } } // Disable nodejs custom inspection across the app diff --git a/packages/cli/package.json b/packages/cli/package.json index 1bdbbc6add11a..6cdd3eba88099 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -42,7 +42,7 @@ "workflow" ], "engines": { - "node": ">=18.10" + "node": ">=18.17 <= 22" }, "files": [ "bin",