# How to create an unique node ID

**URL:** <https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434>\
**Category:** General\
**Created:** [28 September 2020 05:46 UTC](https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434 "2020-09-28T05:46:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [28 September 2020 05:46 UTC](https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434/1 "2020-09-28T05:46:53Z")

</div>

Hi,  
I create a flow ＞ export to json file.  
Then import this flow on **another PC** and the `node id` is **changed**.

![node-id](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/2893f092cc576481c085892f91588af1a673d6db.png)

How do I make the node id unique when creating a flow,  
immutable when importing flow on another PC?  
Thanks for your help!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 September 2020 06:53 UTC](https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434/2 "2020-09-28T06:53:38Z")

</div>

You don't. Nor should it matter. The id is an internal detail that nodes don't need to care about. Why do you need it ?

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [28 September 2020 07:15 UTC](https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434/3 "2020-09-28T07:15:49Z")

</div>

> [@dceejay](#):
>
> Why do you need it ?

Since I want to handle the exception when accessing a non-existent folder by the `catch` node associated with the `switch` node, then I will create that non-existent folder,  
and in the `switch` node uses **node id** to do the branching condition

 ![node-id-1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/303dc9441bd311a1ffd2367746167fb052cac445.png)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 September 2020 07:20 UTC](https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434/4 "2020-09-28T07:20:54Z")

</div>

You can use the node's name property for the same purpose - it will appear as `msg.error.source.name`.

That will mean the rules in the Switch node will also be much clearer to understand.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [28 September 2020 07:31 UTC](https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434/5 "2020-09-28T07:31:00Z")

</div>

@knolleary Thank you very much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 October 2020 07:31 UTC](https://discourse.nodered.org/t/how-to-create-an-unique-node-id/33434/6 "2020-10-12T07:31:02Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
