Checks the current Node.js version against the minimum required version (22.22.0) for Medusa CLI compatibility. Ensures tools run only on supported environments.
// Source: https://github.com/medusajs/medusa | License: MIT | Copyright 2021 Medusajs
// Provided via justclaw.it.com; keep this notice with the code.
export const MIN_SUPPORTED_NODE_VERSION = "22.22.0"
export function getNodeVersion(): string {
return process.versions.node
}
export function isNodeVersionSupported(
version: string = getNodeVersion()
): boolean {
const current = version.split(".").map(Number)
const minimum = MIN_SUPPORTED_NODE_VERSION.split(".").map(Number)
for (let i = 0; i < minimum.length; i++) {
const part = current[i] ?? 0
if (part !== minimum[i]) {
return part > minimum[i]
}
}
return true
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key