# Nodes with internal variables and "context"

**URL:** <https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205>\
**Category:** General\
**Created:** [16 March 2020 21:07 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205 "2020-03-16T21:07:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [16 March 2020 21:07 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/1 "2020-03-16T21:07:08Z")

</div>

In the editor screen you can see any context data for nodes using the `context` mode - top right of window - either by clicking on the icon or selecting it from the menu.

![Screenshot from 2020-03-17 08-02-57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3bf558a82bb27099eda5ab9d5775088cf8b8bc73.png)

This works for function nodes, but it doesn't work for _pre-built_ nodes which have their internal values.

Can/could it be possible to see them via this?

I am asking because I have been debugging stuff and need to know what some _pre-built_ nodes have inside them, but can't get to or see.

Just a question.

---

<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:** [16 March 2020 21:14 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/2 "2020-03-16T21:14:44Z")

</div>

> [@Trying\_to\_learn](#):
>
> Can/could it be possible to see them via this?

Most of the nodes don't use context to store their internal state. They would need rewriting to use context in order to make their values visible in the context sidebar. In may cases, it wouldn't be suitable to do that.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 March 2020 21:24 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/3 "2020-03-16T21:24:04Z")

</div>

You can see the internals of the running Node-RED system by using Node.js's `--inspect` debugging option.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [16 March 2020 21:29 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/4 "2020-03-16T21:29:55Z")

</div>

Thanks @knolleary and @TotallyInformation.

Julian,

As an example, I am using the `node-red-contrib-counter` node.

It gets _stuck_ somewhere and I want to see the _count_ value in the node.

I'm not sure how to apply what you say so I can (just hypothetically speaking) hover the mouse over the node and see the _count_ value.

With `function` nodes I set the right side of the screen - as mentioned - and I can see the context stuff.

But as Nic' has said: They aren't using context to store their internal values.

That node is a recent example.

Does that help with helping me find a way to see their values?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 March 2020 22:43 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/5 "2020-03-16T22:43:14Z")

</div>

> [@Trying\_to\_learn](#):
>
> I'm not sure how to apply what you say so I can (just hypothetically speaking) hover the mouse over the node and see the _count_ value.

Well, it isn't going to be quite that simple. You need to run Node-RED under --inspect and then pause it as soon as it starts. Then you can step through things.

If you want to inspect a particular node, you can manually add a breakpoint in the node.

It takes some practice and some knowledge - another thing to learn 😉

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [16 March 2020 22:48 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/6 "2020-03-16T22:48:20Z")

</div>

Yeah.

Thanks.

Ok. So with that knowledge I shall have to do some thinking.

So, going on what you said, I have to start NR from the CLI/Terminal and run it as:  
`node-red --inspect` yeah?

I guess I could also go to the other end and just stick `debug` nodes on the output of said nodes and _log_ their output.

Looking at/in the `debug` node there is the `system console` option. But `info` doesn't really elaborate on that.  
If I have 3 nodes doing that I'm guessing I need 3 _system consoles_ open?

I'll maybe play with that now for a while and get a feel of how it works.  
But if you could help confirm my thoughts; it would be appreciated.

I just tried that and have an `inject` node connected to a `debug` node and ticked the `system console` option ticked.

I press the `inject` and....... I see the output at the right of the screen, but _system console_.....

Where is it?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 March 2020 00:04 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/7 "2020-03-17T00:04:16Z")

</div>

> [@Trying\_to\_learn](#):
>
> So, going on what you said, I have to start NR from the CLI/Terminal and run it as:  
> `node-red --inspect` yeah?

I have this in my package.json file's scripts section.

```auto
node --inspect node_modules/node-red/red.js --userDir ./data

```

(Just remember that I have Node-RED installed locally not globally which is why that looks a little different. You will need to know where the global installed version of Node-RED exists, you can find that by running `which node-red` in a Linux terminal.)

> [@Trying\_to\_learn](#):
>
> I guess I could also go to the other end and just stick `debug` nodes on the output of said nodes and _log_ their output.

That won't tell you what is happening internally though will it? If that is what you really want.

> [@Trying\_to\_learn](#):
>
> Looking at/in the `debug` node there is the `system console` option. But `info` doesn't really elaborate on that.  
> If I have 3 nodes doing that I'm guessing I need 3 _system consoles_ open?

No, debug output can either go to the debug panel, the Node-RED log or the node's status line, that's it. If you choose console output, everything goes to the Node-RED log.

To view the log depends on how your are running Node-RED. If you run manually from a terminal (console), then you see the output in the same place. If you ran a default install (on a Pi for example), you have to use the journalctl command to show the output of the log.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 March 2020 04:39 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/8 "2020-03-17T04:39:18Z")

</div>

Thanks.

Yeah, I found something similar to what you said (`sudo journalctl -f -u nodered -o cat`).

But that is all nice, but not congruent with what is said in the `debug` node:  
ie: system console.

To me it is a misnomer of sorts.

Since (by default) it is a ....... I don't even know what/where/which is the actual file name used. Guessing `nodered`........ The `debug` node text should be more correct (for people like me) in indicating where this file is.

As said: There is **nothing** written in the _information_ part of the node.  
Maybe just including that would help.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 March 2020 10:27 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/9 "2020-03-17T10:27:12Z")

</div>

On a Pi it goes to `/var/log/syslog` and if you run node-red in a terminal (ie system console) using the node-red command or node-red-start then it also appears there. That is where the term 'system console' comes from, you will find the term used commonly in the Linux environment.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 March 2020 16:15 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/10 "2020-03-17T16:15:09Z")

</div>

> [@Trying\_to\_learn](#):
>
> The `debug` node text should be more correct (for people like me) in indicating where this file is. As said: There is **nothing** written in the _information_ part of the node. Maybe just including that would help.

Perhaps. Why not head over to the #docs channel in slack and make a suggestion? You may well be asked to contribute the change to the docs.

Of course, there is a basic expectation that people have some understanding of the system they are hosting Node-RED on. After all, NR is a server component. The Raspberry Pi sometimes gives us, I think, unrealistic expectations in that it makes it so easy to get started with running a massively powerful computer server right their on our desktop. It is easy to forget the underlying complexity.

Anyway, you've triggered me now. I'm going to write #4 in an occasional series of Node-RED FAQ blog posts. "How to access the Node-RED logs". 🙂

You will find it here once I've posted it:

> **[Node-RED Q & A](https://it.knightnet.org.uk/kb/nr-qa/)**
>
> Node-RED Questions and Answers.
> Node-RED is a flow-based (visual) programming tool. These pages have some information that may be currently missing from the documentation or may expand on it.

---

<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:** [16 May 2020 16:16 UTC](https://discourse.nodered.org/t/nodes-with-internal-variables-and-context/23205/11 "2020-05-16T16:16:28Z")

</div>

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