Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
How do I make a node-red node that is already on a flow obey the default values of a newly-added property?

Initially, this is my node configurations.

RED.nodes.registerType('HelloWorld', {
  category: 'HelloWorld',
  defaults: {
    firstProp: {value: false}
  },
}

This helloworld node is then placed on a flow.

Then, I added another property, secondProp to the configuration and restart node-red.

RED.nodes.registerType('HelloWorld', {
  category: 'HelloWorld',
  defaults: {
    firstProp: {value: false}
    secondProp: {value: true}
  },
}

When I export the flow, I notice the secondProp is set to false. I had expected it to be set to the default which is true

[
{
    "id": "04abe6r5baqs16dc",
    ...
    "firstProp": false,
    "secondProp": false, //expected it to be true
    "x": 290,
    "y": 360
}
]

May I know how do I resolve this and ensure the existing custom nodes on the flow obey the default values of a newly-added property?

NOTE:

When I pull the custom node and place it on the flow, it doesn't have this issue i.e., the secondProp value is true.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

One of the node-red maintainer commented

The flow file is not modified just because you modified the custom node src. You would have to handle any in-place upgrades in oneditprepare. This is normal behaviour as far as I can see.

So as a workaround, we can only do like this

RED.nodes.registerType('HelloWorld', {
  category: 'HelloWorld',
  defaults: {
    firstProp: {value: false}
  },
  oneditprepare: {
    if (this.secondProp === undefined) {
      this.secondProp = true;
    }
  }
}

Note that this will require us to open the edit dialog of the node for it to take effect.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda