表达式常见问题#
¥Expressions common issues
以下是一些与 expressions 相关的常见错误和问题,以及解决或故障排除步骤。
¥Here are some common errors and issues related to expressions and steps to resolve or troubleshoot them.
第 0 项中的 'JSON 输出' 包含无效的 JSON#
¥The 'JSON Output' in item 0 contains invalid JSON
当你使用 JSON 模式但未提供有效的 JSON 对象时,会发生此错误。根据 JSON 对象的问题,错误有时会显示为 The 'JSON Output' in item 0 does not contain a valid JSON object。
¥This error occurs when you use JSON mode but don't provide a valid JSON object. Depending on the problem with the JSON object, the error sometimes display as The 'JSON Output' in item 0 does not contain a valid JSON object.
要解决此问题,请确保你提供的代码是有效的 JSON:
¥To resolve this, make sure that the code you provide is valid JSON:
- 使用 JSON 验证器 检查 JSON。
¥Check the JSON with a JSON validator.
- 检查你的 JSON 对象是否引用了未定义的输入数据。这可能是由于传入的数据并非始终包含相同的字段造成的。
¥Check that your JSON object doesn't reference undefined input data. This may occur if the incoming data doesn't always include the same fields.
无法获取表达式的数据#
¥Can't get data for expression
当 n8n 无法检索表达式引用的数据时,会出现此错误。通常,当前面的节点尚未运行时,就会发生这种情况。
¥This error occurs when n8n can't retrieve the data referenced by an expression. Often, this happens when the preceding node hasn't been run yet.
此模式的另一种变体可能显示为 Referenced node is unexecuted。在这种情况下,此错误的完整文本将以这种格式告诉你哪个节点未执行:
¥Another variation of this may appear as Referenced node is unexecuted. In that case, the full text of this error will tell you the exact node that isn't executing in this format:
表达式引用了节点 '<节点名称>',但尚未执行。你可以更改表达式,或者重新配置工作流,以确保该节点首先执行。
¥An expression references the node '<node-name>', but it hasn’t been executed yet. Either change the expression, or re-wire your workflow to make sure that node executes first.
要开始故障排除,请测试工作流直至指定节点。
¥To begin troubleshooting, test the workflow up to the named node.
对于使用 JavaScript 或其他自定义代码的节点,你可以通过检查以下内容来判断之前的节点是否已执行,然后再尝试使用其值:
¥For nodes that use JavaScript or other custom code, you can check if a previous node has executed before trying to use its value by checking the following:
1 | |
例如,此 JSON 引用了输入数据的参数。如果你在未将此步骤连接到其他节点的情况下进行测试,则会显示此错误:
¥As an example, this JSON references the parameters of the input data. This error will display if you test this step without connecting it to another node:
1 2 | |
无效的语法#
¥Invalid syntax
当你使用的表达式存在语法错误时,会发生此错误。
¥This error occurs when you use an expression that has a syntax error.
例如,此 JSON 中的表达式包含尾随句点,这会导致语法错误:
¥For example, the expression in this JSON includes a trailing period, which results in an invalid syntax error:
1 2 3 | |
要解决此错误,请检查你的 表达式语法,确保它们符合预期格式。
¥To resolve this error, check your expression syntax to make sure they follow the expected format.