n8n-code-javascript
它能做什么
这份指南可以帮你在 n8n(一款自动化工具)中编写 JavaScript 代码。对于其他 n8n 工具无法完成的较复杂编程任务,它很有用。
适用场景
- ✓当你需要进行复杂计算或应用自定义业务逻辑时。
- ✓当你需要处理结构复杂的 API 响应时。
- ✓当你需要以更高级的方式汇总来自不同来源的数据时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/n8n-code-javascript/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“如何在 n8n 中使用 JavaScript 转换输入数据?”
每周 5 个新技能,1 分钟读完。
工作原理
n8n 允许你编写自己的 JavaScript 代码来处理数据。它还提供了一些特殊工具,用来获取前面步骤的信息,并向其他服务发送请求。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
JavaScript Code Node
Expert guidance for writing JavaScript code in n8n Code nodes.
Detailed Guide
Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.
When to Use Code Node
Use Code node when:
- ✅ Complex transformations requiring multiple steps
- ✅ Custom calculations or business logic
- ✅ Recursive operations
- ✅ API response parsing with complex structure
- ✅ Multi-step conditionals
- ✅ Data aggregation across items
Consider other nodes when:
- ❌ Simple field mapping → Use Set node
- ❌ Basic filtering → Use Filter node
- ❌ Simple conditionals → Use IF or Switch node
- ❌ HTTP requests only → Use HTTP Request node
Code node excels at: Complex logic that would require chaining many simple nodes
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题
什么时候应该用 Code 节点,而不是其他节点?
当你需要进行复杂的多步骤转换、自定义计算、递归逻辑、解析复杂的 API 响应、多步条件判断或数据汇总时,使用 Code 节点。对于字段映射或简单过滤等较简单的任务,请使用“Set”、“Filter”或“IF”等节点。
“$input”“$json”“$node”和“$helpers”是什么?
这些是 n8n 提供的特殊快捷方式,让你的 JavaScript 代码能够方便地读取输入数据、前面节点的信息,并使用发送请求或处理日期等实用函数。
这份指南能替代测试代码吗?
不能。这份指南只提供指导,你仍然需要在自己的环境中验证和测试代码,确保它正确且安全地运行。
详情
作者的原始描述
Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
热度
- GitHub 星标
- 48k
- 排名
- #5268
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。