n8n-io/n8n · error · Error

Failed to parse node types from ${jsonPath}: ${error instanc

Error message

Failed to parse node types from ${jsonPath}: ${error instanceof Error ? error.message : String(error)}

What it means

loadNodeTypes() reads the nodes.json file and JSON.parse()s it; if the content is not valid JSON it rethrows, embedding the underlying parse error message and the path. This is the loader used by the generate-types pipeline.

Source

Thrown at packages/@n8n/workflow-sdk/src/generate-types/generate-types.ts:4247

// =============================================================================
// Node Loading
// =============================================================================

/**
 * Load node types from JSON file
 * @param jsonPath Path to the nodes.json file
 * @param packageName Package name to prefix node names with (e.g., 'n8n-nodes-base')
 */
export async function loadNodeTypes(
	jsonPath: string,
	packageName?: string,
): Promise<NodeTypeDescription[]> {
	const content = await fs.promises.readFile(jsonPath, 'utf-8');
	let nodes: NodeTypeDescription[];
	try {
		nodes = JSON.parse(content) as NodeTypeDescription[];
	} catch (error) {
		throw new Error(
			`Failed to parse node types from ${jsonPath}: ${error instanceof Error ? error.message : String(error)}`,
		);
	}

	// If package name provided and node names don't have package prefix, add it
	if (packageName) {
		for (const node of nodes) {
			if (!node.name.includes('.')) {
				node.name = `${packageName}.${node.name}`;
			}
		}
	}

	return nodes;
}

/**
 * Convert a node to its tool variant.

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Validate the file with a JSON linter (e.g. node -e "JSON.parse(require('fs').readFileSync('nodes.json','utf8'))") to see the exact syntax error.
  2. Regenerate nodes.json by rerunning the package build.
  3. Confirm the file is non-empty and contains an array of NodeTypeDescription objects.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate JSON before relying on loadNodeTypes.
import * as fs from 'fs';
const raw = fs.readFileSync(jsonPath, 'utf-8');
try { JSON.parse(raw); } catch (e) {
  throw new Error(`nodes.json at ${jsonPath} is not valid JSON: ${(e as Error).message}`);
}

Try / catch

try {
  const types = await loadNodeTypes(jsonPath, packageName);
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Failed to parse node types')) {
    // regenerate nodes.json from the build, then retry
    throw e;
  }
  throw e;
}

Prevention

When it happens

Trigger: nodes.json is truncated, contains trailing commas or // comments, is an empty file, holds an HTML error page instead of JSON, or has a stray BOM/encoding issue.

Common situations: Hand-edited nodes.json with JSON5 syntax; a partial/failed write left a truncated file; a 404 page was saved as nodes.json; encoding conversion introduced invalid bytes.

Understand the failure class

Related errors


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