项目链接错误(Item linking errors)#
在 n8n 中,你可以引用来自任意之前节点的数据。这不一定非要是紧挨着的节点:可以是链中的任何之前节点。当引用更早的节点时,你可以使用表达式语法 $(node_name).item。
🌐 In n8n you can reference data from any previous node. This doesn't have to be the node just before: it can be any previous node in the chain. When referencing nodes further back, you use the expression syntax $(node_name).item.
不同项目的线程图。由于项目链接的关系,你可以使用 $('Get famous movie actors').item 获取每部电影的参与者。
由于前一个节点中可能包含多个项目,n8n 需要知道使用哪一个。当使用 .item 时,n8n 会在后台为你处理这个问题。有关其工作原理的详细信息,请参阅 Item linking concepts。
🌐 Since the previous node can have multiple items in it, n8n needs to know which one to use. When using .item, n8n figures this out for you behind the scenes. Refer to Item linking concepts for detailed information on how this works.
.item 在信息缺失时会失败。为了确定使用哪个项目,n8n 会为每个项目在工作流的节点之间维护一条线程。对于某个给定的项目,这条线程会告诉 n8n 是哪些先前节点中的项目生成了它。要在某个特定的先前节点中找到匹配的项目,n8n 会沿着这条线程向回追溯,直到到达该节点为止。
使用 .item 时,n8n 会在以下情况下显示错误:
🌐 When using .item, n8n displays an error when:
- 线程已断开
- 线程指向前一个节点中的多个项目(因为不确定要使用哪个项目)。
要解决这些错误,你可以选择避免使用 .item,或者修复根本原因。
🌐 To solve these errors, you can either avoid using .item, or fix the root cause.
你可以通过使用 .first()、.last() 或 .all()[index] 来避免使用 .item。这些方法要求你知道目标项在目标节点输出项中的位置。有关这些方法的更多详细信息,请参阅 内置方法和变量 | 其他节点的输出。
🌐 You can avoid .item by using .first(), .last() or .all()[index] instead. They require you to know the position of the item that you’re targeting within the target node's output items. Refer to Built in methods and variables | Output of other nodes for more detail on these methods.
根本原因的修复取决于具体的错误。
🌐 The fix for the root cause depends on the exact error.
修复“前一个节点缺少表达式信息”(Fix for 'Info for expressions missing from previous node')#
如果你看到以下错误信息:
🌐 If you see this error message:
错误:前一个节点缺少表达式的信息
链中有一个节点没有返回配对信息。这里的解决方案取决于前一个节点的类型:
🌐 There's a node in the chain that doesn't return pairing information. The solution here depends on the type of the previous node:
- 代码节点:确保返回节点用于生成每个输出项的输入项。有关更多信息,请参阅代码节点中的项目链接。
- 自定义或社区节点:节点创建者需要更新节点,以返回它使用哪些输入项目来生成每个输出项目。有关更多信息,请参阅节点创建者的项目关联。
修复“表达式有多个匹配项”问题(Fix for 'Multiple matching items for expression')#
这是错误消息:
🌐 This is the error message:
错误:表达式匹配到多个项
有时 n8n 会使用多个项目来创建一个单一项目。例如总结(Summarize)、聚合(Aggregate)和合并(Merge)节点。这些节点可以将来自多个项目的信息合并。
🌐 Sometimes n8n uses multiple items to create a single item. Examples include the Summarize, Aggregate, and Merge nodes. These nodes can combine information from multiple items.
当你使用 .item 并且存在多个可能的匹配时,n8n 不知道应该使用哪一个。为了解决这个问题,你可以选择以下方法之一:
🌐 When you use .item and there are multiple possible matches, n8n doesn't know which one to use. To solve this you can either:
- 请改用
.first()、.last()或.all()[index]。有关这些方法的更多详细信息,请参阅 内置方法和变量 | 其他节点的输出。 - 引用包含相同信息但不包含多个匹配项的其他节点。
