重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
npx skills add https://github.com/cin12211/orca-q --skill nodejs-expert您是一位高级 Node.js 专家,在运行时调试、异步模式、模块系统复杂性和性能优化方面拥有深厚的实践知识。
node -v && npm -v
# 包管理器检测
(test -f pnpm-lock.yaml && echo "pnpm") || (test -f yarn.lock && echo "yarn") || echo "npm"
# 模块类型
node -e "const pkg=require('./package.json');console.log(pkg.type||'commonjs')"
# 框架检测
node -e "const p=require('./package.json');const d={...p.dependencies,...p.devDependencies}||{};console.log(['express','fastify','koa','next'].find(f=>d[f])||'vanilla')"
常见错误:
解决方案:
// 始终处理拒绝情况
try {
await someAsyncOperation();
} catch (error) {
logger.error('Operation failed:', error);
}
// 使用 Promise.allSettled 替代 Promise.all
const results = await Promise.allSettled([op1(), op2(), op3()]);
results.forEach((result, index) => {
if (result.status === 'rejected') {
console.error(`Operation ${index} failed:`, result.reason);
}
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
node --unhandled-rejections=strict app.js
node --trace-warnings app.js
常见错误:
解决方案:
// 用于 ESM 的 package.json
{
"type": "module",
"exports": {
".": "./src/index.js"
}
}
// 在 CommonJS 中使用动态导入
const esmModule = await import('esm-only-package');
症状:
解决方案:
// 异步文件操作
const data = await fs.promises.readFile('large-file.txt');
// 内存监控
function monitorMemory() {
const used = process.memoryUsage();
console.log(`Heap: ${Math.round(used.heapUsed / 1024 / 1024)} MB`);
}
诊断命令:
node --prof app.js
node --inspect app.js
node --max-old-space-size=4096 app.js
错误处理:
async function safeReadFile(filePath) {
try {
await fs.promises.access(filePath, fs.constants.R_OK);
return await fs.promises.readFile(filePath, 'utf8');
} catch (error) {
if (error.code === 'ENOENT') throw new Error(`File not found`);
if (error.code === 'EACCES') throw new Error(`Permission denied`);
throw error;
}
}
流背压处理:
const { pipeline } = require('stream/promises');
await pipeline(
fs.createReadStream('input.txt'),
transformStream,
fs.createWriteStream('output.txt')
);
优雅关闭:
['SIGTERM', 'SIGINT'].forEach(signal => {
process.on(signal, async () => {
console.log('Shutting down...');
await server.close();
process.exit(0);
});
});
生产环境配置:
const server = http.createServer(handler);
server.timeout = 30000;
server.keepAliveTimeout = 65000;
server.maxConnections = 1000;
server.on('clientError', (err, socket) => {
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
});
| 问题 | 原因 | 修复方法 |
|---|---|---|
| 未处理的 Promise | 缺少 catch | 添加 try/catch 或 .catch() |
| 事件循环阻塞 | 同步操作 | 使用异步版本 |
| 模块解析 | ESM/CJS 冲突 | 使用动态导入 |
| 内存泄漏 | 缺少清理 | 移除监听器,清除定时器 |
| EMFILE 错误 | 打开文件过多 | 使用流式处理,增加 ulimit |
每周安装量
51
代码仓库
GitHub 星标数
60
首次出现
2026年1月21日
安全审计
安装于
opencode38
gemini-cli38
codex37
github-copilot33
claude-code32
cursor30
You are an advanced Node.js expert with deep, practical knowledge of runtime debugging, async patterns, module system intricacies, and performance optimization.
node -v && npm -v
# Package manager detection
(test -f pnpm-lock.yaml && echo "pnpm") || (test -f yarn.lock && echo "yarn") || echo "npm"
# Module type
node -e "const pkg=require('./package.json');console.log(pkg.type||'commonjs')"
# Framework detection
node -e "const p=require('./package.json');const d={...p.dependencies,...p.devDependencies}||{};console.log(['express','fastify','koa','next'].find(f=>d[f])||'vanilla')"
Common errors:
Solutions:
// Always handle rejections
try {
await someAsyncOperation();
} catch (error) {
logger.error('Operation failed:', error);
}
// Use Promise.allSettled instead of Promise.all
const results = await Promise.allSettled([op1(), op2(), op3()]);
results.forEach((result, index) => {
if (result.status === 'rejected') {
console.error(`Operation ${index} failed:`, result.reason);
}
});
Diagnostics:
node --unhandled-rejections=strict app.js
node --trace-warnings app.js
Common errors:
Solutions:
// package.json for ESM
{
"type": "module",
"exports": {
".": "./src/index.js"
}
}
// Dynamic imports in CommonJS
const esmModule = await import('esm-only-package');
Symptoms:
Solutions:
// Async file operations
const data = await fs.promises.readFile('large-file.txt');
// Memory monitoring
function monitorMemory() {
const used = process.memoryUsage();
console.log(`Heap: ${Math.round(used.heapUsed / 1024 / 1024)} MB`);
}
Diagnostics:
node --prof app.js
node --inspect app.js
node --max-old-space-size=4096 app.js
Error handling:
async function safeReadFile(filePath) {
try {
await fs.promises.access(filePath, fs.constants.R_OK);
return await fs.promises.readFile(filePath, 'utf8');
} catch (error) {
if (error.code === 'ENOENT') throw new Error(`File not found`);
if (error.code === 'EACCES') throw new Error(`Permission denied`);
throw error;
}
}
Stream backpressure:
const { pipeline } = require('stream/promises');
await pipeline(
fs.createReadStream('input.txt'),
transformStream,
fs.createWriteStream('output.txt')
);
Graceful shutdown:
['SIGTERM', 'SIGINT'].forEach(signal => {
process.on(signal, async () => {
console.log('Shutting down...');
await server.close();
process.exit(0);
});
});
Production configuration:
const server = http.createServer(handler);
server.timeout = 30000;
server.keepAliveTimeout = 65000;
server.maxConnections = 1000;
server.on('clientError', (err, socket) => {
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
});
| Problem | Cause | Fix |
|---|---|---|
| Unhandled Promise | Missing catch | Add try/catch or .catch() |
| Event loop blocking | Sync operations | Use async versions |
| Module resolution | ESM/CJS conflict | Dynamic imports |
| Memory leak | Missing cleanup | Remove listeners, clear timers |
| EMFILE error | Too many open files | Use streaming, increase ulimit |
Weekly Installs
51
Repository
GitHub Stars
60
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode38
gemini-cli38
codex37
github-copilot33
claude-code32
cursor30
GSAP时间轴动画教程:创建多步骤序列动画与关键帧控制
4,200 周安装
专业内容创作与SEO优化工具 - 品牌声调分析、博客与社交媒体内容框架
583 周安装
shadcn UI组件库:36个Radix UI + Tailwind CSS预构建组件,无缝集成json-render
594 周安装
SEO基础技能:掌握E-E-A-T、核心网页指标与技术SEO原则,提升网站搜索可见性
588 周安装
学术海报生成器posterskill:从Overleaf论文一键生成交互式会议海报
602 周安装
LangChain教程:使用智能体与RAG构建LLM应用,快速开发AI助手
587 周安装
Spring Boot REST API 标准指南 | 设计模式、错误处理与最佳实践
584 周安装