0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

fix: check if node.js minimum version is correct (#4002)

This commit is contained in:
Juan Picado 2023-09-03 08:57:20 +02:00 committed by GitHub
parent c2aa0b6d3f
commit 547ba9a569
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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`);