export function checkVersion() { const v = parseInt(process.version.slice(1)); if (v < MIN_NODE_VERSION || v === 15 || v === 17) { logger.error( `Your node version ${v} is not supported, please upgrade to ${MIN_NODE_VERSION} or above except 15 or 17.`, ); process.exit(1); }}
You can get the current node version using this method — process.version.slice(1)
In this function, there’s a side-effect. process exits if the node version does not meet the criteria defined in the if block.
logger.error logs the error message when the node version is not supported.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.