重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
workers-migration by secondsky/claude-skills
npx skills add https://github.com/secondsky/claude-skills --skill workers-migration将现有应用程序从各种平台迁移到 Cloudflare Workers。
What are you migrating from?
├── AWS Lambda
│ └── Node.js handler? → Lambda adapter pattern
│ └── Python? → Consider Python Workers
│ └── Container/custom runtime? → May need rewrite
├── Vercel/Next.js
│ └── API routes? → Minimal changes with adapter
│ └── Full Next.js app? → Use OpenNext adapter
│ └── Middleware? → Direct Workers equivalent
├── Express/Node.js
│ └── Simple API? → Hono (similar API)
│ └── Complex middleware? → Gradual migration
│ └── Heavy node: usage? → Compatibility layer
└── Other Edge (Deno Deploy, Fastly)
└── Standard Web APIs? → Minimal changes
└── Platform-specific? → Targeted rewrites
| 功能 | Workers | Lambda | Vercel | Express |
|---|---|---|---|---|
| 冷启动 | ~0ms | 100-500ms |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 10-100ms |
| N/A |
| CPU 限制 | 50ms/10ms | 15 分钟 | 10秒 | 无限制 |
| 内存 | 128MB | 10GB | 1GB | 系统内存 |
| 最大响应 | 6MB (流式传输无限制) | 6MB | 4.5MB | 无限制 |
| 全球边缘节点 | 300+ 接入点 | 区域级 | ~20 接入点 | 手动配置 |
| Node.js API | 部分支持 | 完全支持 | 完全支持 | 完全支持 |
| 错误 | 来源 | 原因 | 解决方案 |
|---|---|---|---|
fs is not defined | Lambda/Express | 文件系统访问 | 使用 KV/R2 进行存储 |
Buffer is not defined | Node.js | Node.js 全局对象 | 从 node:buffer 导入 |
process.env undefined | 所有平台 | 环境变量访问模式 | 使用 env 参数 |
setTimeout not returning | Lambda | 异步模式 | 使用 ctx.waitUntil() |
require() not found | Express | CommonJS | 转换为 ESM 导入 |
Exceeded CPU time | 所有平台 | 长时间计算 | 分块处理或使用 DO |
body already consumed | Express | 请求体 | 读取前先克隆 |
Headers not iterable | Lambda | Headers API | 使用 Headers 构造函数 |
crypto.randomBytes | Node.js | Node crypto | 使用 crypto.getRandomValues |
Cannot find module | 所有平台 | 缺少 polyfill | 检查 Workers 兼容性 |
// Before: AWS Lambda
export const handler = async (event, context) => {
const body = JSON.parse(event.body);
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello' }),
};
};
// After: Cloudflare Workers
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const body = await request.json();
return Response.json({ message: 'Hello' });
},
};
// Before: Express
app.use((req, res, next) => {
if (!req.headers.authorization) {
return res.status(401).json({ error: 'Unauthorized' });
}
next();
});
// After: Hono Middleware
app.use('*', async (c, next) => {
if (!c.req.header('Authorization')) {
return c.json({ error: 'Unauthorized' }, 401);
}
await next();
});
// Before: Node.js
const apiKey = process.env.API_KEY;
// After: Workers
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const apiKey = env.API_KEY;
// ...
},
};
Workers 通过兼容性标志支持许多 Node.js API:
// wrangler.jsonc
{
"compatibility_flags": ["nodejs_compat_v2"],
"compatibility_date": "2024-12-01"
}
通过 nodejs_compat_v2 支持:
crypto (大多数方法)buffer (Buffer 类)util (promisify, types)stream (Readable, Writable)events (EventEmitter)path (所有方法)string_decoderassert不支持 (需要替代方案):
fs → 使用 R2/KVchild_process → 不可用cluster → 不适用dgram → 不支持net → 使用 fetch/WebSockettls → 由平台处理| 参考文档 | 加载时机 |
|---|---|
references/lambda-migration.md | 迁移 AWS Lambda 函数时 |
references/vercel-migration.md | 从 Vercel/Next.js 迁移时 |
references/express-migration.md | 迁移 Express/Node.js 应用时 |
references/node-compatibility.md | 遇到 Node.js API 兼容性问题时 |
workers-runtime-apis - Workers 中可用的 APIworkers-performance - 优化技巧cloudflare-worker-base - 基础 Workers 设置每周安装量
66
代码仓库
GitHub 星标数
93
首次出现
2026年1月25日
安全审计
安装于
claude-code59
gemini-cli53
cursor53
codex52
opencode52
github-copilot50
Migrate existing applications to Cloudflare Workers from various platforms.
What are you migrating from?
├── AWS Lambda
│ └── Node.js handler? → Lambda adapter pattern
│ └── Python? → Consider Python Workers
│ └── Container/custom runtime? → May need rewrite
├── Vercel/Next.js
│ └── API routes? → Minimal changes with adapter
│ └── Full Next.js app? → Use OpenNext adapter
│ └── Middleware? → Direct Workers equivalent
├── Express/Node.js
│ └── Simple API? → Hono (similar API)
│ └── Complex middleware? → Gradual migration
│ └── Heavy node: usage? → Compatibility layer
└── Other Edge (Deno Deploy, Fastly)
└── Standard Web APIs? → Minimal changes
└── Platform-specific? → Targeted rewrites
| Feature | Workers | Lambda | Vercel | Express |
|---|---|---|---|---|
| Cold Start | ~0ms | 100-500ms | 10-100ms | N/A |
| CPU Limit | 50ms/10ms | 15 min | 10s | None |
| Memory | 128MB | 10GB | 1GB | System |
| Max Response | 6MB (stream unlimited) | 6MB | 4.5MB | None |
| Global Edge | 300+ PoPs | Regional | ~20 PoPs | Manual |
| Node.js APIs | Partial | Full | Full | Full |
| Error | From | Cause | Solution |
|---|---|---|---|
fs is not defined | Lambda/Express | File system access | Use KV/R2 for storage |
Buffer is not defined | Node.js | Node.js globals | Import from node:buffer |
process.env undefined | All | Env access pattern | Use env parameter |
// Before: AWS Lambda
export const handler = async (event, context) => {
const body = JSON.parse(event.body);
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello' }),
};
};
// After: Cloudflare Workers
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const body = await request.json();
return Response.json({ message: 'Hello' });
},
};
// Before: Express
app.use((req, res, next) => {
if (!req.headers.authorization) {
return res.status(401).json({ error: 'Unauthorized' });
}
next();
});
// After: Hono Middleware
app.use('*', async (c, next) => {
if (!c.req.header('Authorization')) {
return c.json({ error: 'Unauthorized' }, 401);
}
await next();
});
// Before: Node.js
const apiKey = process.env.API_KEY;
// After: Workers
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const apiKey = env.API_KEY;
// ...
},
};
Workers support many Node.js APIs via compatibility flags:
// wrangler.jsonc
{
"compatibility_flags": ["nodejs_compat_v2"],
"compatibility_date": "2024-12-01"
}
Supported with nodejs_compat_v2:
crypto (most methods)buffer (Buffer class)util (promisify, types)stream (Readable, Writable)events (EventEmitter)path (all methods)string_decoderassertNot Supported (need alternatives):
fs → Use R2/KVchild_process → Not possiblecluster → Not applicabledgram → Not supportednet → Use fetch/WebSockettls → Handled by platform| Reference | Load When |
|---|---|
references/lambda-migration.md | Migrating AWS Lambda functions |
references/vercel-migration.md | Migrating from Vercel/Next.js |
references/express-migration.md | Migrating Express/Node.js apps |
references/node-compatibility.md | Node.js API compatibility issues |
workers-runtime-apis - Available APIs in Workersworkers-performance - Optimization techniquescloudflare-worker-base - Basic Workers setupWeekly Installs
66
Repository
GitHub Stars
93
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code59
gemini-cli53
cursor53
codex52
opencode52
github-copilot50
程序化SEO完整指南:自动化创建海量优化页面,提升长尾关键词排名
372 周安装
Cypress 自动化测试指南:E2E 与组件测试最佳实践、安装配置与故障排除
371 周安装
ARIS 自主机器学习研究工具:夜间自动生成AI论文的Claude Code技能
360 周安装
API契约测试指南:Pact、OpenAPI验证与微服务测试最佳实践
366 周安装
AI文档生成与验证工具 - 自动检测项目类型、生成API文档、检查覆盖率
363 周安装
Google Workspace AI 代理技能 - 全面集成 Docs、Sheets、Gmail、Drive 等 API
361 周安装
setTimeout not returning| Lambda |
| Async patterns |
Use ctx.waitUntil() |
require() not found | Express | CommonJS | Convert to ESM imports |
Exceeded CPU time | All | Long computation | Chunk or use DO |
body already consumed | Express | Request body | Clone before read |
Headers not iterable | Lambda | Headers API | Use Headers constructor |
crypto.randomBytes | Node.js | Node crypto | Use crypto.getRandomValues |
Cannot find module | All | Missing polyfill | Check Workers compatibility |