网易云音乐 API 标准版部署
基于 NeteaseCloudMusicApi 项目。
环境要求
- Node.js 14+
推荐方式
| 方式 | 适合场景 | 入口 |
|---|---|---|
npm install | 长期运行、希望固定依赖 | npm install NeteaseCloudMusicApi@latest |
npx | 快速试跑 | npx NeteaseCloudMusicApi@latest |
bunx | 使用 Bun 快速启动 | bunx NeteaseCloudMusicApi@latest |
| Docker Compose | 容器化长期运行 | oven/bun:alpine + bunx NeteaseCloudMusicApi |
::: note npm install 更适合长期部署;npx / bunx 首次运行会临时下载包,更适合快速验证。 :::
NPM 安装部署
1. 初始化目录
shell
mkdir netease-cloud-music-api
cd netease-cloud-music-api
npm init -y2. 安装依赖
shell
npm install NeteaseCloudMusicApi@latest3. 运行
shell
npx NeteaseCloudMusicApi4. 自定义端口
Linux/macOS
shell
PORT=4000 npx NeteaseCloudMusicApiWindows
bat
set PORT=4000 && npx NeteaseCloudMusicApiNPX / Bunx 快速运行
默认端口 3000
shell
npx NeteaseCloudMusicApi@latestshell
bunx NeteaseCloudMusicApi@latest自定义端口
shell
PORT=4000 npx NeteaseCloudMusicApi@latestshell
PORT=4000 bunx NeteaseCloudMusicApi@latestWindows
bat
set PORT=4000 && npx NeteaseCloudMusicApi@latest
set PORT=4000 && bunx NeteaseCloudMusicApi@latestDocker Compose 部署
这里改用 Bun 基础镜像在容器内直接执行 bunx NeteaseCloudMusicApi,避免依赖长期未更新的旧镜像。
yaml
services:
ncm-api:
image: oven/bun:alpine
container_name: ncm-api
restart: always
environment:
- TZ=Asia/Shanghai
ports:
- "127.0.0.1:3000:3000"
command: bunx NeteaseCloudMusicApi
networks:
- 1panel-network
deploy:
resources:
limits:
memory: 256M
networks:
1panel-network:
external: true启动命令:
shell
docker compose up -d如果你不是在 1Panel 下部署,可以把 1panel-network 替换成自己的网络名,或者直接删除 networks 配置让 Compose 使用默认网络。
常见问题
登录失败
如果遇到无法登录的问题,请尝试使用邮箱登录。