Bt Node Project Deploy logo

Bt Node Project Deploy

Community
aaPanel
bt-node-project-deploy

在宝塔面板上部署 Node.js 项目(nodejs/general/pm2 三种类型,含 Nginx 域名/反代), 并在项目启动失败或访问异常时排错。 当用户要求把本机已有的 Node 项目目录部署成面板可管理的项目(含 node 版本、依赖安装、 Nginx 代理/域名、pm2 守护),或 Node 项目启动失败/访问异常需要排查根因时使用。 触发关键词:部署 Node、Node 项目部署、nodejs 部署、npm 项目部署、PM2 部署、 Node 项目启动失败、npm 起不来、Node 报错、502、访问异常、pm2 errored、Cannot find module。 日常的启停/状态/日志/改配置等简单操作不依赖本 SOP,直接按工具描述调用即可。

Overview

PublisheraaPanel
Repositorybtpanel-skills
Skill namebt-node-project-deploy
Stars
43
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by aaPanel on GitHub. Read the source before you install it.

Installation

Install the Bt Node Project Deploy AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/aaPanel/btpanel-skills/tree/main/assets/bt-skills/bt-node-project-deploy
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/aaPanel/btpanel-skills.git /tmp/btpanel-skills
mkdir -p .claude/skills
cp -r /tmp/btpanel-skills/assets/bt-skills/bt-node-project-deploy .claude/skills/bt-node-project-deploy
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Bt Node Project Deploy in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Bt Node Project Deploy on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Bt Node Project Deploy is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Node.js 项目部署与启动排错 SOP

停止。执行任何操作前,必须完整阅读本文档。 本 Skill 的工具均指 bt_agent_mcp 插件暴露的 MCP 工具;同一能力在宝塔 AI 内置端可能有不同命名,按当前环境可用工具调用。 本 SOP 只覆盖两个主场景:① 部署 Node 项目;② 启动排错。其他简单操作(状态查看、启停、日志、域名、改配置、删除)不做 SOP,直接使用工具。


核心规则

  1. 先只读侦察,再执行变更 —— 部署前必须完成项目分析;排错先读日志,不盲目重启。
  2. 创建后必须验证启动 —— "创建成功"不算完,必须确认进程存活 + 监听端口 + 日志无致命错误;验证失败即转入场景二。
  3. 删除项目属高风险,必须先获得用户明确确认;启停/重启/改配置属中风险,操作前说明影响。
  4. Node 版本匹配 —— 创建前用 NodeVersion(action='list') 检测已装版本;package.json 的 engines.node 不符时优先换已装版本或安装。
  5. 端口唯一性 —— 创建/改端口前检查占用;绑外网必须有端口(bind_extranet 依赖 port)。
  6. 绑域名 = 自动反代 —— Node 的反代由 nginx 模板按 project_config.port 自动生成(proxy_pass http://127.0.0.1:{port}),无独立反代步骤。访问异常时核对:NodeProjectInfo 的 listen(实际监听端口)vs 配置端口(反代目标)是否一致,不一致 = 502。
  7. 依赖先行 —— nodejs 类型缺 node_modules 启动必失败。创建时 install_deps=true 或创建后装依赖再启动。
  8. 每个任务最多调用 15 次工具,超出后汇总当前发现并停止。
  9. 禁止操作:删除项目目录/源码、rm -rf 项目目录、修改宝塔/插件自身文件、读取插件 data/ 凭据。

场景一:部署 Node 项目

Step 0 —— 预检

  1. 确认任务确为"部署新 Node 项目"(非排错/运维)。
  2. 确定项目类型:nodejs(package.json scripts)/ general(直接指定启动文件)/ pm2(守护+cluster+自愈)。
  3. 需要外网域名访问时,确认 Nginx 已安装;否则只能本机/内网访问。

Step 1 —— 定位项目目录

  • 用户给出 project_cwd(项目根,含 package.json),或:
  • 用文件工具 Glob(pattern='**/package.json') / LS(path=...) 定位(排除 node_modules、dist、build 等构建目录)。
  • 校验:目录存在、含 package.json(nodejs/pm2 必需;general 可没有)、非敏感目录(/etc、/boot、插件 data/ 等)。

Step 2 —— 分析项目(部署前必须)

调用 NodeProjectCreate(project_cwd=..., analyze_only=true)(只读,不创建)。返回:

  1. package.json 的 name/version、engines.node、dependencies 数量。
  2. scripts 启动项列表(nodejs 类型的 project_script 从这里选)。
  3. node_modules 是否存在(缺 → 需先装依赖)。
  4. port/port_hints:从入口文件启发式探测的端口(仅供参考)。

决策:

  • nodejs 类型:确认启动脚本名(start/dev/自定义),即 project_script。
  • pm2 类型:确认入口文件(js 或 ecosystem 配置)与 cluster 实例数。
  • 无端口或启发式不准 → 询问用户,创建时显式传 port(绑外网必需)。

Step 3 —— Node 版本确认 / 安装

  1. NodeVersion(action='list') 检测已装版本与可用包管理器(npm/yarn/pnpm)。
  2. 若返回 plugin_installed=false:nodejs 版本管理器插件未装,先调 SoftwareInstall(name='nodejs') 安装插件(可再用 SoftwareList(name='nodejs') 查进度),装完继续。
  3. 需要新装版本时,用 NodeVersion(action='online', lts_only=true, page=...) 浏览可安装版本(按版本从新到旧排序、本地分页,lts_only=false 看全部;每项 installed 标记是否已装),从中挑选稳定版。
  4. 对照 engines.node(无则默认 LTS)。
  5. 已装 → 记录版本号(如 v20.15.0);无 → 询问用户后 NodeVersion(action='install', version=..., install_pm2=<pm2 类型时 true>)(插件安装,较慢,装完用 list 确认)。

Step 4 —— 创建项目(注册)

调用 NodeProjectCreate(project_type=..., project_name=..., project_cwd=..., nodejs_version=..., ...)。 按类型传参:

  • nodejs:project_script(scripts key,如 'start')、pkg_manager(npm/yarn/pnpm)。
  • general:project_file(启动文件绝对路径)、project_args(可选)。同时必须传 nodejs_version(三类型均必填、须已安装——general 漏传会直接报错,不是可选项)。
  • pm2:project_file(js 入口或 ecosystem 配置,内容检测自动路由)、cluster、watch、max_memory_limit。pm2 类型项目启动依赖该 node 版本已全局安装 pm2——创建工具会自动检测,该版本缺 pm2 时自动调插件安装(结果 data.pm2_auto_installed 标记);也可手动 NodeVersion(action='module', version=<nodejs_version>, modules=['pm2'])。
  • 通用:port(绑外网必需)、run_user(默认 www)、env(注意:面板对 nodejs 类型的 env 注入有缺陷——存了但不写进启动脚本,需要环境变量的项目建议用 general 类型)、install_deps(package.json 有依赖且未装 node_modules 时给 true)、release_firewall(需放行端口时)、domains=['域名'](绑域名+自动反代)。

外网映射:要域名访问 → 传 domains(自动写 server_name + proxy_pass 127.0.0.1:{port},无需额外反代步骤)。install_deps=true 较慢(npm install),可接受等待。

Step 5 —— 启动验证(强制)

创建后调用 NodeProjectInfo(project_name=...) 依次确认:

  1. 进程存活(run=true)。
  2. 应用端口在 listen 列表(listen_ok=true)。
  3. 用返回的 log_files 里应用日志路径,调 filesystem Read 看尾部无致命异常(Cannot find module/EADDRINUSE/throw er)。

⚠️ pm2 类型不要信创建返回的「已自动启动」:daemon 可能未持久化(run:false、listen 空但 listen_ok=true)。创建后必须: ① 立即 NodeProjectInfo 核验 run=true; ② 间隔几秒再次 NodeProjectInfo 复检持久化(本地等待即可,不调长工具); ③ 不持久 → NodeProjectControl(action='start') 重拉再复检。

  • 全通过 → 按"完成汇报"收尾。
  • 任一失败 → 转场景二排错。

场景二:启动排错

适用:部署后验证失败、或用户报"Node 项目启动失败/访问异常"。

Step 0 —— 快速定位现状(只读)

并行收集,不跳过:

  1. NodeProjectInfo(project_name=...):run、listen、listen_ok(区分"进程没起来"与"起来了但访问不了");pm2 项目看状态。
  2. 读应用日志尾部:用返回的 log_files 应用日志路径调 filesystem Read,找异常堆栈根因。
  3. 已知配置:项目类型、入口/脚本、node 版本、端口、是否已装依赖。

收集后按症状进分支。

分支 A —— 启动失败(进程起不来 / run=false)

按日志根因对号入座:

日志特征根因处置
Error: Cannot find module 'x'依赖未安装NodeProjectCreate(project_cwd=<项目目录>, nodejs_version=..., project_script=..., install_deps=true) 或装依赖后重启
EADDRINUSE / Port 3000 is already in use端口被占NodeProjectModify(action='config', port=新端口) 后 NodeProjectControl(action='restart')
npm ERR! Missing script: "start"scripts key 名错NodeProjectModify(action='config', project_script=正确key)
throw er; Unhandled 'error' event启动即崩(端口/环境)看堆栈中具体原因;换端口或补 env
ERR_REQUIRE_ESM / 语法错误模块系统/代码问题检查入口与 package.json 的 type 字段
node 版本引擎不符engines.node 不匹配NodeProjectModify(action='config', nodejs_version=匹配版本) 或 NodeVersion(action='install')
进程起来但 pid 无/端口没监听启动后立即退出读日志尾找 exit/Error 根因
  • 无明确报错 → 查 NodeProjectInfo:run、listen、启动命令是否完整;log_files 有无 pm2 err.log。
  • 修复后回到场景一 Step 5 重新验证。

分支 B —— 访问异常(502/无法访问,但进程活着)

  1. NodeProjectInfo:进程在跑、端口在听吗?→ 不在则回分支 A。
  2. 反代端口匹配:看 listen(实际监听)vs project_config.port(反代目标)是否一致;grep proxy_pass node_<name>.conf(/www/server/panel/vhost/nginx/node_<name>.conf)确认反代指向 127.0.0.1:{实际端口}。
    • 端口改了没同步 → NodeProjectModify(action='config', port=实际端口)(有 domains 时自动重写反代)。
    • 反代指向错误端口 → 同上。
  3. 域名绑定:bind_extranet 是否开、域名是否在 nginx server_name(未绑 → NodeProjectModify(action='add_domain', domains=[...]))。
  4. 读 nginx error log(log_files 里 /www/wwwlogs/<name>.error.log)进一步定位。
  5. 修正后验证。

分支 C —— PM2 项目异常

  1. NodeProjectInfo 看 pm2 状态(online/stopped/errored)。
  2. errored(崩溃超限)→ 读 log_files 里 pm2 err.log 找根因;修复后用 NodeProjectControl(action='restart') 重启。
  3. 读 /www/wwwlogs/pm2/<name>/out.log|err.log。
  4. 依赖问题 → 同分支 A。

分支 D —— 进程在但无响应 / 卡死

  1. 应用日志尾部看异常/死锁(filesystem Read)。
  2. SystemInfo() 看系统资源(CPU/内存/负载)。
  3. 汇报,建议用户确认后 NodeProjectControl(action='restart') 重启。

日常运维速查(简单操作,直接按工具描述调用)

需求工具
查看项目列表/状态NodeProjectInfo()(project_name 留空)
查看单项目详情(含日志路径)NodeProjectInfo(project_name=...)
启动 / 停止 / 重启NodeProjectControl(project_name, action='start'/'stop'/'restart')
看应用日志 / pm2 / nginx 日志NodeProjectInfo 返回 log_files → filesystem Read
改脚本/参数/node 版本/端口/用户/环境/内存NodeProjectModify(action='config', ...)(重启生效)
加域名 / 删域名(至少留一个)NodeProjectModify(action='add_domain'/'remove_domain', domains=[...])
node 版本检测 / 在线浏览 / 安装NodeVersion(action='list'/'online'/'install', ...)
给 node 版本装全局模块(pm2/pnpm/yarn 等)NodeVersion(action='module', version=<nodejs_version>, modules=['pm2'])
删除项目(高风险,先确认)NodeProjectDelete(project_name=...)(保留目录源码)

完成汇报模板(部署成功)

返回:项目名 / 项目类型 / 目录 / node 版本 / 运行用户 / 监听端口;若绑域名:访问地址 + nginx 配置路径;应用日志路径;启动验证结果(进程/端口/日志);遗留隐患提示(依赖未装、env 未注入等)。

Frequently asked questions

What does the Bt Node Project Deploy AI skill do?

在宝塔面板上部署 Node.js 项目(nodejs/general/pm2 三种类型,含 Nginx 域名/反代), 并在项目启动失败或访问异常时排错。 当用户要求把本机已有的 Node 项目目录部署成面板可管理的项目(含 node 版本、依赖安装、 Nginx 代理/域名、pm2 守护),或 Node 项目启动失败/访问异常需要排查根因时使用。 触发关键词:部署 Node、Node 项目部署、nodejs 部署、npm 项目部署、PM2 部署、 Node 项目启动失败、npm 起不来、Node 报错、502、访问异常、pm2 errored、Cannot find module。 日常的启停/状态/日志/改配置等简单操作不依赖本 SOP,直接按工具描述调用即可。

Why use Bt Node Project Deploy on TypingMind?

Because you install it once and use it with any model. Bt Node Project Deploy is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Bt Node Project Deploy in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/aaPanel/btpanel-skills/tree/main/assets/bt-skills/bt-node-project-deploy. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Bt Node Project Deploy?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Bt Node Project Deploy?

As many as you like. As long as a model supports skills, you can use Bt Node Project Deploy with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Bt Node Project Deploy AI skill free?

Yes. It is published on GitHub by aaPanel under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇