Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

Add Node.js version validation in CLI command to ensure compatibility with minimum required version 20, enhancing user experience and error handling.

vholik56bb7f54b7b3
diff --git a/packages/cli/src/commands/create.ts b/packages/cli/src/commands/create.ts
index e4ec53112..beea562e9 100644
--- a/packages/cli/src/commands/create.ts
+++ b/packages/cli/src/commands/create.ts
@@ -20,6 +20,7 @@ import terminalLink from "terminal-link";
import validateProjectName from "validate-npm-package-name";
const DEFAULT_BRANCH = "main";
+const MIN_SUPPORTED_NODE_VERSION = 20;
const CREATE_TEMPLATES = {
basic: "basic",
@@ -44,6 +45,8 @@ export const create = new Command()
.option("--skip-db", "skip database configuration.", false)
.option("--db-connection-string <string>", "PostgreSQL connection string.")
.action(async (name, opts) => {
+ validateNodeVersion();
+
try {
// Prompt for project name if not provided.
let projectName = name;
@@ -260,3 +263,18 @@ function createTerminalLink(text: string, url: string) {
fallback: (text, url) => `${text}: ${url}`,
});
}
+
+function getNodeVersion(): number {
+ const [major] = process.versions.node.split(".").map(Number);
+ return major;
+}
+
+function validateNodeVersion(): void {
+ const nodeVersion = getNodeVersion();
+ if (nodeVersion < MIN_SUPPORTED_NODE_VERSION) {
+ logger.error(
+ `Mercur requires at least v${MIN_SUPPORTED_NODE_VERSION} of Node.js. You're using v${nodeVersion}. Please install at least v${MIN_SUPPORTED_NODE_VERSION} and try again: https://nodejs.org/en/download`
+ );
+ process.exit(1);
+ }
+}