n8n JavaScript 节点编写
原名:n8n-code-javascript
区分原生节点与 Code 节点,整理输入、输出及批量处理逻辑。
中文 Skills 技能说明
工作流需要自定义处理时,先检查原生节点或表达式是否已经能完成。提供 n8n 版本、节点输入样本、预期输出和已有流程,技能整理 JavaScript Code 节点的运行模式、数据访问、返回结构与 pairedItem,交付代码草稿和边界用例。需要现有 n8n 环境;MCP 工具和关联技能另配,不按文档名称假定工具已存在。外部请求和库调用受实例白名单限制,不能读取未获准凭据;先在测试流程验证空值、批量和错误处理,再确认是否启用。
上游能力依据
上游原始适用说明:Write, review, or debug JavaScript in an n8n Code node. Use when a Code node is already in the workflow (editing it, fixing an error, choosing its mode, making it faster), or when a new one is justified: no native node fits (check the job-to-node table in using-n8n-mcp-skills first) and the job is on the closed list — loops or recursion no node expresses, state across runs, parsing no node handles, an allowlisted library, heavy all-items work, or one short node replacing 4+ glue nodes. Covers $input/$json/$node in code, this.helpers, Luxon, SplitInBatches loops, cross-iteration data, pairedItem, per-item performance, and the \"Why Code:\" note. Filtering, totals, dedupe, sorting, joins, file formats and API paging have native nodes (Filter, Summarize, Remove Duplicates, Sort, Merge, Extract From File, HTTP Request): see n8n-node-configuration. EXCEPTION — for the AI-agent-callable Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode), use n8n-code-tool; it has a different runtime contract.
上游 SKILL.md 主要章节(保留原文标题):
- Before you write a Code node
- Quick Start
- Essential Rules
- Mode Selection Guide
- Run Once for All Items (Recommended - Default)
- Run Once for Each Item
- Why "All Items" is faster — the per-item boundary
- Data Access Patterns
- Critical: Webhook Data Structure
- Return Format Requirements
使用边界
先核对运行环境、账号、区域、依赖和最小权限。创建资源、改配置、发布服务或产生费用前必须让使用者确认。
作者、翻译与许可证
- 原作者
- Romuald Członkowski 与 n8n-skills contributors
- 中文翻译
- CEOFans翻译
- 许可证
- MIT
- 上游来源
- https://github.com/czlonkowski/n8n-skills/tree/e037563e101749e630e6688d121d04529fe6ee7b/skills/n8n-code-javascript
适用范围
平台:linux、macos、windows;标签:MCP 与工具、n8n JavaScript 节点编写、开源技能
安全提示
基础静态扫描不等于绝对安全。技能可能调用命令、浏览器、云服务或本地文件,请在最小权限环境中使用,高风险操作必须人工确认。
如发现侵权、许可证或安全问题,可在本页前台提交投诉,管理员复核后可立即下架。