diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 7b7b3f7..6e03565 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -14,15 +14,15 @@ jobs: include: - os: ubuntu-latest platform: linux - target: node18-linux-x64 + target: node22-linux-x64 output: precompiled/app - os: windows-latest platform: win - target: node18-win-x64 + target: node22-win-x64 output: precompiled/app.exe - os: macos-latest platform: macos - target: node18-macos-x64 + target: node22-macos-x64 output: precompiled/app steps: @@ -32,7 +32,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v6 with: - node-version: '18' + node-version: '24' - name: Setup pnpm run: npm install -g pnpm@9 diff --git a/README.MD b/README.MD index 74401a8..e59f17f 100644 --- a/README.MD +++ b/README.MD @@ -163,7 +163,7 @@ docker run -d -p 3000:3000 moefurina/ncm-api:latest ```bash #!/bin/bash export PORT=9000 - /var/lang/node16/bin/node app.js + /var/lang/node22/bin/node app.js ``` 4. 完成部署后,访问 API 网关的 URL 即可 diff --git a/app.js b/app.js index 1c662e0..220da89 100755 --- a/app.js +++ b/app.js @@ -3,6 +3,17 @@ const fs = require('fs') const path = require('path') const tmpPath = require('os').tmpdir() +// engines 字段只在 npm/pnpm 安装时生效,直接 node app.js 不会被拦截, +// 这里给出友好的最低版本检查(>=22,与 package.json engines 保持一致) +const [major] = process.versions.node.split('.').map(Number) +if (major < 22) { + console.error( + `[${new Date().toLocaleString()}] Node.js >= 22 is required (current: ${process.versions.node}). ` + + '请升级 Node.js 后重试 / Please upgrade Node.js to v22 or newer.', + ) + process.exit(1) +} + async function start() { // 检测是否存在 anonymous_token 文件,没有则生成 if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) { diff --git a/package.json b/package.json index 38aaca9..ebec1bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@neteasecloudmusicapienhanced/api", - "version": "4.41.1", + "version": "5.0.0", "description": "全网最全的网易云音乐API接口 || A revival project for NeteaseCloudMusicApi Node.js Services (Half Refactor & Enhanced)", "scripts": { "dev": "nodemon app.js",