@ -15,20 +15,27 @@ dayjs.extend(require("dayjs/plugin/customParseFormat"));
require ( "dotenv" ) . config ( ) ;
require ( "dotenv" ) . config ( ) ;
// Check Node.js Version
// Check Node.js Version
const nodeVersion = parseInt ( process . versions . node . split ( "." ) [ 0 ] ) ;
const nodeVersion = process . versions . node ;
const requiredVersion = 14 ;
// Get the required Node.js version from package.json
const requiredNodeVersions = require ( "../package.json" ) . engines . node ;
const bannedNodeVersions = " < 14 || 20.0.* || 20.1.* || 20.2.* || 20.3.* " ;
console . log ( ` Your Node.js version: ${ nodeVersion } ` ) ;
console . log ( ` Your Node.js version: ${ nodeVersion } ` ) ;
// See more: https://github.com/louislam/uptime-kuma/issues/3138
const semver = require ( "semver" ) ;
if ( nodeVersion >= 20 ) {
const requiredNodeVersionsComma = requiredNodeVersions . split ( "||" ) . map ( ( version ) => version . trim ( ) ) . join ( ", " ) ;
console . warn ( "\x1b[31m%s\x1b[0m" , "Warning: Uptime Kuma is currently not stable on Node.js >= 20, please use Node.js 18." ) ;
}
if ( nodeVersion < requiredVersion ) {
// Exit Uptime Kuma immediately if the Node.js version is banned
console . error ( ` Error: Your Node.js version is not supported, please upgrade to Node.js >= ${ requiredVersion } . ` ) ;
if ( semver . satisfies ( nodeVersion , bannedNodeVersions ) ) {
console . error ( "\x1b[31m%s\x1b[0m" , ` Error: Your Node.js version: ${ nodeVersion } is not supported, please upgrade your Node.js to ${ requiredNodeVersionsComma } . ` ) ;
process . exit ( - 1 ) ;
process . exit ( - 1 ) ;
}
}
// Warning if the Node.js version is not in the support list, but it maybe still works
if ( ! semver . satisfies ( nodeVersion , requiredNodeVersions ) ) {
console . warn ( "\x1b[31m%s\x1b[0m" , ` Warning: Your Node.js version: ${ nodeVersion } is not officially supported, please upgrade your Node.js to ${ requiredNodeVersionsComma } . ` ) ;
}
const args = require ( "args-parser" ) ( process . argv ) ;
const args = require ( "args-parser" ) ( process . argv ) ;
const { sleep , log , getRandomInt , genSecret , isDev } = require ( "../src/util" ) ;
const { sleep , log , getRandomInt , genSecret , isDev } = require ( "../src/util" ) ;
const config = require ( "./config" ) ;
const config = require ( "./config" ) ;