跳到正文
Skillpedia
通用编程48k · #5268

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/n8n-code-javascript/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5268
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能