Semver icon

Semver

Semantic Versioning utilities for version management

Overview

This node provides semantic versioning (semver) comparison utilities, specifically for comparing two version strings. The "Greater Than" operation checks if the first version is strictly greater than the second version according to semver rules.

Common scenarios where this node is useful include:

  • Automating deployment pipelines by checking if a new software version is newer than the current one.
  • Validating version upgrades in package management or dependency resolution workflows.
  • Conditional logic based on version precedence in CI/CD or release automation.

For example, given versions "1.2.3" and "1.2.4", the node can determine that "1.2.4" is greater, enabling workflows to trigger updates only when newer versions are available.

Properties

Name Meaning
Version 1 The first version string to compare (e.g., "1.2.3").
Version 2 The second version string to compare (e.g., "1.2.4").
Options Additional options affecting comparison behavior:
- Loose: Whether to use loose parsing of version strings (boolean).
- Include Prerelease: Whether to consider prerelease versions in comparisons (boolean).
- RTL (Right to Left): Not applicable for this resource-operation combination.

Output

The node outputs a JSON object with the following structure:

{
  "operation": "gt",
  "version1": "1.2.3",
  "version2": "1.2.4",
  "result": false
}
  • operation: The performed operation, here always "gt" for "greater than".
  • version1: The first input version string.
  • version2: The second input version string.
  • result: A boolean indicating whether version1 is greater than version2.

No binary data output is produced by this node.

Dependencies

  • This node depends on the external semver library for semantic version parsing and comparison.
  • No external API keys or services are required.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Invalid version strings: If either version string is not a valid semver format, the comparison may fail or return unexpected results. Ensure inputs conform to semantic versioning standards.
  • Loose parsing option: Enabling "Loose" parsing allows non-strict version formats but may lead to ambiguous comparisons. Use it only if necessary.
  • Prerelease handling: By default, prerelease versions are excluded from some comparisons. Enable "Include Prerelease" if you want to consider them.
  • Error messages: Errors typically indicate invalid input versions or unknown resources/operations. Verify property values and ensure the resource is set to "Comparison" and operation to "Greater Than".

Links and References

Discussion