跳转至

节点版本管理#

n8n支持节点版本管理。您可以通过引入新版本来对现有节点进行更改,而不会破坏现有的行为。

了解n8n如何决定加载哪个节点版本:

  • 如果用户使用版本1构建并保存工作流,即使您创建并发布节点的版本2,n8n在该工作流中仍然继续使用版本1。
  • 当用户创建新工作流并浏览节点时,n8n始终加载节点的最新版本。

版本管理类型受节点样式限制

如果您使用声明式样式构建节点,则无法使用完整版本管理。

轻量版本管理#

所有节点类型都可以使用此功能。

一个节点可以包含多个版本,允许在不复制代码的情况下进行小版本增量更新。要使用此功能:

  1. 将主version参数更改为数组,并添加您的版本号,包括您现有的版本。
  2. 然后,您可以在任何对象的displayOptions中使用@version访问版本参数(以控制n8n显示对象的版本)。您还可以使用const nodeVersion = this.getNode().typeVersion;从函数中查询版本。

例如,假设您要对声明式节点教程中的NasaPics节点添加版本管理,然后配置一个资源,使得n8n只在节点的版本2中显示它。在您的基本NasaPics.node.ts文件中:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{
    displayName: 'NASA Pics',
    name: 'NasaPics',
    icon: 'file:nasapics.svg',
    // List the available versions
    version: [1,2,3],
    // More basic parameters here
    properties: [
        // Add a resource that's only displayed for version2
        {
            displayName: 'Resource name',
            // More resource parameters
            displayOptions: {
                show: {
                    '@version': 2,
                },
            },
        },
    ],
}

Full versioning#

This isn't available for declarative-style nodes.

As an example, refer to the Mattermost node.

Full versioning summary:

  • The base node file should extend NodeVersionedType instead of INodeType.
  • The base node file should contain a description including the defaultVersion (usually the latest), other basic node metadata such as name, and a list of versions. It shouldn't contain any node functionality.
  • n8n recommends using v1, v2, and so on, for version folder names.
此页面是否
💬 微信

🚀 与作者交流

关注公众号
n8n实战笔记公众号
n8n实战笔记
📚 教程 💡 案例 🔧 技巧
添加微信
添加作者微信
1对1 专业指导
⚡ 快答 🎯 定制 🚀 支持