From 547ba9a56932705896b7e9b03c8c581c863396b4 Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Sun, 3 Sep 2023 08:57:20 +0200 Subject: [PATCH] fix: check if node.js minimum version is correct (#4002) --- src/lib/cli.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/cli.ts b/src/lib/cli.ts index 197b698f4..e0f953f83 100644 --- a/src/lib/cli.ts +++ b/src/lib/cli.ts @@ -1,7 +1,16 @@ #!/usr/bin/env node -/* eslint no-sync:0 */ -/* eslint no-empty:0 */ +const nodeVersion = process.version; +const versionParts = nodeVersion.slice(1).split('.'); + +const majorVersion = parseInt(versionParts[0]); +const minorVersion = parseInt(versionParts[1]); + +if (majorVersion < 16 || (majorVersion === 16 && minorVersion < 0)) { + throw Error( + '"Error: Your Node.js version is not supported. Please upgrade to Node.js 16 or higher for this application to work correctly.' + ); +} if (process.getuid && process.getuid() === 0) { process.emitWarning(`Verdaccio doesn't need superuser privileges. don't run it under root`);