mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Support Node.js 20 again (#3431)
* Support >= Node.js 20.4.0 * Improve the Node.js warning, ban 20.0 to 20.3 * Update * Minor
This commit is contained in:
parent
baf5613dfa
commit
25c8196641
4 changed files with 20 additions and 11 deletions
|
@ -54,7 +54,7 @@ Requirements:
|
||||||
- ✅ Major Linux distros such as Debian, Ubuntu, CentOS, Fedora and ArchLinux etc.
|
- ✅ Major Linux distros such as Debian, Ubuntu, CentOS, Fedora and ArchLinux etc.
|
||||||
- ✅ Windows 10 (x64), Windows Server 2012 R2 (x64) or higher
|
- ✅ Windows 10 (x64), Windows Server 2012 R2 (x64) or higher
|
||||||
- ❌ Replit / Heroku
|
- ❌ Replit / Heroku
|
||||||
- [Node.js](https://nodejs.org/en/download/) 14 / 16 / 18 (20 is not supported)
|
- [Node.js](https://nodejs.org/en/download/) 14 / 16 / 18 / 20.4
|
||||||
- [npm](https://docs.npmjs.com/cli/) >= 7
|
- [npm](https://docs.npmjs.com/cli/) >= 7
|
||||||
- [Git](https://git-scm.com/downloads)
|
- [Git](https://git-scm.com/downloads)
|
||||||
- [pm2](https://pm2.keymetrics.io/) - For running Uptime Kuma in the background
|
- [pm2](https://pm2.keymetrics.io/) - For running Uptime Kuma in the background
|
||||||
|
|
3
package-lock.json
generated
3
package-lock.json
generated
|
@ -62,6 +62,7 @@
|
||||||
"qs": "~6.10.4",
|
"qs": "~6.10.4",
|
||||||
"redbean-node": "~0.3.0",
|
"redbean-node": "~0.3.0",
|
||||||
"redis": "~4.5.1",
|
"redis": "~4.5.1",
|
||||||
|
"semver": "^7.5.4",
|
||||||
"socket.io": "~4.6.1",
|
"socket.io": "~4.6.1",
|
||||||
"socket.io-client": "~4.6.1",
|
"socket.io-client": "~4.6.1",
|
||||||
"socks-proxy-agent": "6.1.1",
|
"socks-proxy-agent": "6.1.1",
|
||||||
|
@ -134,7 +135,7 @@
|
||||||
"whatwg-url": "~12.0.1"
|
"whatwg-url": "~12.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "14.* || 16.* || 18.*"
|
"node": "14.* || 16.* || 18.* || >= 20.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@aashutoshrathi/word-wrap": {
|
"node_modules/@aashutoshrathi/word-wrap": {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"url": "https://github.com/louislam/uptime-kuma.git"
|
"url": "https://github.com/louislam/uptime-kuma.git"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "14.* || 16.* || 18.*"
|
"node": "14 || 16 || 18 || >= 20.4.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install-legacy": "npm install",
|
"install-legacy": "npm install",
|
||||||
|
@ -121,6 +121,7 @@
|
||||||
"qs": "~6.10.4",
|
"qs": "~6.10.4",
|
||||||
"redbean-node": "~0.3.0",
|
"redbean-node": "~0.3.0",
|
||||||
"redis": "~4.5.1",
|
"redis": "~4.5.1",
|
||||||
|
"semver": "~7.5.4",
|
||||||
"socket.io": "~4.6.1",
|
"socket.io": "~4.6.1",
|
||||||
"socket.io-client": "~4.6.1",
|
"socket.io-client": "~4.6.1",
|
||||||
"socks-proxy-agent": "6.1.1",
|
"socks-proxy-agent": "6.1.1",
|
||||||
|
|
|
@ -15,18 +15,25 @@ 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.");
|
|
||||||
|
// Exit Uptime Kuma immediately if the Node.js version is banned
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeVersion < requiredVersion) {
|
// Warning if the Node.js version is not in the support list, but it maybe still works
|
||||||
console.error(`Error: Your Node.js version is not supported, please upgrade to Node.js >= ${requiredVersion}.`);
|
if (!semver.satisfies(nodeVersion, requiredNodeVersions)) {
|
||||||
process.exit(-1);
|
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);
|
||||||
|
|
Loading…
Reference in a new issue