Skip to content

Commit

Permalink
fix(core): Enforce nodejs version consistently (#11323)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored Oct 21, 2024
1 parent dd3ab3b commit 0fa2e8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions packages/cli/bin/n8n
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"workflow"
],
"engines": {
"node": ">=18.10"
"node": ">=18.17 <= 22"
},
"files": [
"bin",
Expand Down

0 comments on commit 0fa2e8c

Please sign in to comment.