feat(create-medusa-app, medusa): check Node.js version before installation. (#8452)

Check before installation with `create-medusa-app` and `medusa new` whether the current node version is >= 20. If not, exit with an error.
This commit is contained in:
Shahed Nasser
2024-08-06 10:15:17 +03:00
committed by GitHub
parent 413e29837c
commit 98f42e8995
6 changed files with 24 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
"prepublishOnly": "cross-env NODE_ENV=production tsc --build"
},
"dependencies": {
"@medusajs/utils": "^1.11.9",
"boxen": "^5",
"chalk": "^5.2.0",
"commander": "^10.0.1",

View File

@@ -9,7 +9,6 @@ import waitOn from "wait-on"
import ora, { Ora } from "ora"
import fs from "fs"
import path from "path"
import isEmailImported from "validator/lib/isEmail.js"
import logMessage from "../utils/log-message.js"
import createAbortController, {
isAbortError,
@@ -27,6 +26,7 @@ import {
installNextjsStarter,
startNextjsStarter,
} from "../utils/nextjs-utils.js"
import { getNodeVersion, MIN_SUPPORTED_NODE_VERSION } from "@medusajs/utils"
const slugify = slugifyType.default
@@ -53,6 +53,13 @@ export default async ({
withNextjsStarter = false,
verbose = false,
}: CreateOptions) => {
const nodeVersion = getNodeVersion()
if (nodeVersion < MIN_SUPPORTED_NODE_VERSION) {
logMessage({
message: `Medusa requires at least v20 of Node.js. You're using v${nodeVersion}. Please install at least v20 and try again: https://nodejs.org/en/download`,
type: "error"
})
}
track("CREATE_CLI_CMA")
const spinner: Ora = ora()