← Files RivetARCHIVED FILE
node_modules/rivet-design/scripts/verify-node-version.cjs
1.52 KB · Nov 5, 2026 · 12:09 UTC
'use strict';
const MINIMUM_NODE_VERSION = [22, 16, 0];
const MINIMUM_CURRENT_NODE_MAJOR = 24;
const MINIMUM_NODE_VERSION_LABEL = '22.16+ (22.x) or 24+';
const parseNodeVersion = (version) => {
const parts = version.replace(/^v/, '').split('.');
return MINIMUM_NODE_VERSION.map((_, index) =>
Number.parseInt(parts[index] ?? '', 10),
);
};
const assertSupportedNodeVersion = (version) => {
const parsedVersion = parseNodeVersion(version);
const firstDifferenceIndex = parsedVersion.findIndex(
(part, index) => part !== MINIMUM_NODE_VERSION[index],
);
const isValid = parsedVersion.every(Number.isInteger);
const isSupported =
isValid &&
(parsedVersion[0] >= MINIMUM_CURRENT_NODE_MAJOR ||
(parsedVersion[0] === MINIMUM_NODE_VERSION[0] &&
(firstDifferenceIndex === -1 ||
parsedVersion[firstDifferenceIndex] >
MINIMUM_NODE_VERSION[firstDifferenceIndex])));
if (!isSupported) {
throw new Error(
`Rivet requires Node.js ${MINIMUM_NODE_VERSION_LABEL}. ` +
`Current version: ${version}. Upgrade Node.js, then install ` +
'`rivet-design@latest` again.',
);
}
};
const verifyCurrentNodeVersion = () => {
try {
assertSupportedNodeVersion(globalThis.process.versions.node);
} catch (error) {
globalThis.console.error(
`\n${error instanceof Error ? error.message : String(error)}\n`,
);
globalThis.process.exitCode = 1;
}
};
if (require.main === module) {
verifyCurrentNodeVersion();
}
module.exports = { assertSupportedNodeVersion };
SHA-256: 7b66d3d7f2c41991e5d059a73239b50f6808daa59f8369a714808ae6c439ef29