项目链接错误#
在 n8n 中,您可以引用任何前面节点的数据。这不一定是紧邻的前一个节点:可以是链中的任何前面节点。当引用更远的节点时,您使用表达式语法 $(node_name).item。
不同项目的线程图。由于项目链接,您可以使用 $('Get famous movie actors').item 获取每部电影的演员。
由于前一个节点中可能有多个项目,n8n 需要知道使用哪一个。当使用 .item 时,n8n 会在幕后为您解决这个问题。有关其工作原理的详细信息,请参阅项目链接概念。
如果信息缺失,.item 会失败。为了确定使用哪个项目,n8n 为每个项目维护一个通过工作流节点的线程。对于给定的项目,此线程告诉 n8n 是哪些前面节点中的项目生成了它。要在给定的前面节点中找到匹配的项目,n8n 沿着此线程回溯,直到到达所讨论的节点。
当使用 .item 时,在以下情况下 n8n 会显示错误:
- 线程断开
- 线程指向前一个节点中的多个项目(因为不清楚使用哪一个)
要解决这些错误,您可以避免使用 .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 Referencing previous nodes for more detail on these methods.
根本原因的修复取决于具体错误。
修复"前一个节点缺少表达式信息"#
如果您看到此错误消息:
ERROR: Info for expression missing from previous node
链中有一个节点不返回配对信息。这里的解决方案取决于前一个节点的类型:
- Code nodes: make sure you return which input items the node used to produce each output item. Refer to Preserving linking in the Code node for more information.
- Custom or community nodes: the node creator needs to update the node to return which input items it uses to produce each output item. Refer to Item linking for node creators for more information.
修复"表达式的多个匹配项目"#
这是错误消息:
ERROR: Multiple matching items for expression
有时 n8n 使用多个项目来创建单个项目。示例包括汇总、聚合和合并节点。这些节点可以组合来自多个项目的信息。
当您使用 .item 并且有多个可能的匹配时,n8n 不知道使用哪一个。要解决此问题,您可以:
- Use
.first(),.last()or.all()[index]instead. Refer to Referencing previous nodes for more detail on these methods. - Reference a different node that contains the same information, but doesn't have multiple matching items.
