n8n-io/n8n · error · Error

Cannot call .output() on the workflow builder. Use .output()

Error message

Cannot call .output() on the workflow builder. Use .output() on a node variable instead: myNode.output(0).to(targetNode)

What it means

The WorkflowBuilder object itself does not have a meaningful .output() — output selection is per-node. The method exists on the builder only to intercept the common mistake of writing workflow.output(0).to(...) instead of myNode.output(0).to(...). Calling it always throws. Use .output() on a node handle returned by trigger()/node()/add().

Source

Thrown at packages/@n8n/workflow-sdk/src/workflow-builder.ts:450

		}

		if (target === null || target === undefined) {
			this._currentNode = sourceKey;
			this._currentOutput = 0;
			return this;
		}

		this._currentNode = sourceKey;
		this._currentOutput = outputIndex;
		this.to(target as NodeInstance<string, string, unknown>);
		// Re-anchor the cursor on the branching node so the next sibling branch wires correctly.
		this._currentNode = sourceKey;
		this._currentOutput = 0;
		return this;
	}

	output(): never {
		throw new Error(
			'Cannot call .output() on the workflow builder. ' +
				'Use .output() on a node variable instead: myNode.output(0).to(targetNode)',
		);
	}

	input(): never {
		throw new Error(
			'Cannot call .input() on the workflow builder. ' +
				'Use .input() on a node variable instead: myNode.input(1)',
		);
	}

	settings(settings: WorkflowSettings): WorkflowBuilder {
		this._settings = { ...this._settings, ...settings };
		return this;
	}

	connect(

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Capture the node handle: const myNode = node({ type: 'If' }); then myNode.output(0).to(target).
  2. Pass the OutputSelector to workflow.add(): workflow.add(myNode.output(0).to(target)).

Example fix

// before
workflow.output(0).to(target); // throws

// after
const myNode = node({ type: 'Some' });
workflow.add(myNode.output(0).to(target));
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof (wf as any).output === 'function') {
  // .output() on the builder always throws; call it on a node handle instead.
}
const myNode = node({ type: 'Some' });
const selector = myNode.output(0); // correct

Type guard

function isWorkflowBuilder(v: unknown): v is WorkflowBuilder {
  return typeof v === 'object' && v !== null && 'add' in v && 'to' in v && 'settings' in v;
}

Prevention

When it happens

Trigger: Typing workflow.output(0).to(target) instead of first capturing a node handle and calling node.output(0).to(target). Often a copy-paste from node-handle code onto the workflow object.

Common situations: Confusing the workflow-level API with the node-level API; refactoring that loses the node variable reference; IDE autocomplete picking workflow.output because the node handle is out of scope.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/63fd6af65f23f77b. Report an issue: GitHub.