# Where can I find (or enable) an "interactive" console in node-red?

**URL:** <https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905>\
**Category:** General\
**Created:** [19 May 2021 10:55 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905 "2021-05-19T10:55:45Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![abhilash-ingale](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/abhilash-ingale/32/41401_2.png) [@abhilash-ingale](https://discourse.nodered.org/u/abhilash-ingale)\
**Post date:** [4 June 2021 11:10 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/21 "2021-06-04T11:10:34Z")

</div>

No problem. Thanks for the comment.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [4 June 2021 11:29 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/22 "2021-06-04T11:29:35Z")

</div>

> [@Steve-Mcl](#):
>
> There are libs on NPM to convert them to HTML but will take some work to get going

ok - 20 minutes 🙂

* * *

Here is an alternative version that uses [ansi-to-html](https://www.npmjs.com/package/ansi-to-html)

### NOTE:

You will need node-red V1.3.x as this demo uses [function external modules](https://nodered.org/docs/user-guide/writing-functions#using-the-functionexternalmodules-option)

![Us8oCqVmtk](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bffa0bfbd1080ddcd4a2f587feb8c744029b2b92.gif)

```auto
[{"id":"270e0d17.f1c9b2","type":"ui_template","z":"553814a2.1248ec","group":"6d01ec93.b1d374","name":"","order":7,"width":"12","height":"8","format":"\n<div id=\"shell\" style=\"font-family: monospace;\"></div>\n\n<script>\n(function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg) {\n debugger\n $(\"#shell\").html(msg.payload);\n $(\"#shell\").closest(\".nr-dashboard-template\").scrollTop(function() { return this.scrollHeight; });\n }\n });\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":880,"y":2020,"wires":[[]]},{"id":"3e727ae4.147346","type":"exec","z":"553814a2.1248ec","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":630,"y":2100,"wires":[["195bbabe.711bb5"],[],[]]},{"id":"4d08470d.865218","type":"ui_button","z":"553814a2.1248ec","name":"","group":"6d01ec93.b1d374","order":3,"width":"3","height":"1","passthru":false,"label":"time /T","tooltip":"","color":"","bgcolor":"","icon":"","payload":"time /T","payloadType":"str","topic":"topic","topicType":"msg","x":350,"y":2020,"wires":[["3e727ae4.147346","195bbabe.711bb5"]]},{"id":"195bbabe.711bb5","type":"function","z":"553814a2.1248ec","name":"","func":"\nif(!msg.payload) return;\nvar convert = new ansiToHtml();\nconst CR = '\\r';\nconst LF = '\\n';\nconst CRLF = CR+LF;\nlet input = msg.payload + \"\";\ninput = input.replace(new RegExp(CR, 'g'), LF)\ninput = input.replace(new RegExp(CRLF, 'g'), LF)\n\nconst MAXLINES = 200;\nlet data = context.get(\"data\") || [];\nif(msg.topic==\"clear\") {\n data = [];\n} else {\n const lines = input.split(LF);\n data.push(...lines)\n data = data.slice(-MAXLINES);\n}\ncontext.set(\"data\", data);\n\nvar html = convert.toHtml(data.join(\"<br>\"))\nmsg.payload = html;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"ansiToHtml","module":"ansi-to-html"}],"x":700,"y":2020,"wires":[["270e0d17.f1c9b2"]]},{"id":"aacf91fd.8dbd3","type":"ui_button","z":"553814a2.1248ec","name":"","group":"6d01ec93.b1d374","order":4,"width":"3","height":"1","passthru":false,"label":"where node","tooltip":"","color":"","bgcolor":"","icon":"","payload":"where node","payloadType":"str","topic":"topic","topicType":"msg","x":370,"y":2060,"wires":[["3e727ae4.147346","195bbabe.711bb5"]]},{"id":"16e0554b.d16f7b","type":"ui_button","z":"553814a2.1248ec","name":"","group":"6d01ec93.b1d374","order":5,"width":"3","height":"1","passthru":false,"label":"demo ANSI","tooltip":"","color":"","bgcolor":"","icon":"","payload":"where cmd","payloadType":"str","topic":"topic","topicType":"msg","x":370,"y":1960,"wires":[["55a5d564.95fd5c"]]},{"id":"ca6518ec.ca9f78","type":"ui_button","z":"553814a2.1248ec","name":"","group":"6d01ec93.b1d374","order":6,"width":"3","height":"1","passthru":false,"label":"clear","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"clear","topicType":"str","x":350,"y":2140,"wires":[["195bbabe.711bb5"]]},{"id":"14e64a77.db0856","type":"inject","z":"553814a2.1248ec","name":"demo ANSI colrs","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":380,"y":1920,"wires":[["55a5d564.95fd5c"]]},{"id":"55a5d564.95fd5c","type":"function","z":"553814a2.1248ec","name":"","func":"\nvar convert = new ansiToHtml();\n\nmsg.payload = `\\x1b[30mblack\\x1b[37mwhite\nnew line\nanother \\u001b[31mnew\\u001b[0m line\na new line with \\u001b[31mcolor\\u001b[0m embeded`\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"ansiToHtml","module":"ansi-to-html"}],"x":560,"y":1960,"wires":[["195bbabe.711bb5"]]},{"id":"6d01ec93.b1d374","type":"ui_group","name":"UserEntry","tab":"5132060d.4cde48","order":2,"disp":true,"width":"12","collapse":false},{"id":"5132060d.4cde48","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![abhilash-ingale](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/abhilash-ingale/32/41401_2.png) [@abhilash-ingale](https://discourse.nodered.org/u/abhilash-ingale)\
**Post date:** [4 June 2021 11:37 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/23 "2021-06-04T11:37:57Z")

</div>

Woah, that's fast! Thank you @Steve-Mcl for updating the flow.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [4 June 2021 11:39 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/24 "2021-06-04T11:39:22Z")

</div>

Actually, I just edited it to set the font mono-spaced (better for terminal - you might want to re-import the flow from previous thread. Up to you.

---

<div class="post-metadata">

**Author:** ![abhilash-ingale](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/abhilash-ingale/32/41401_2.png) [@abhilash-ingale](https://discourse.nodered.org/u/abhilash-ingale)\
**Post date:** [7 June 2021 15:04 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/25 "2021-06-07T15:04:37Z")

</div>

Hi again @Steve-Mcl , I upgraded my node-red to run your flow but it still says -

```auto
ReferenceError: ansiToHtml is not defined 

```

However, I am unclear why it is says so because I can clearly see ansi-to-html module in `/home/pi/.node-red/node_modules`.

![ansi-to-html](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/7769fa4bba1796e0822b8c2eab9fb5ab7fe28671.png)

I have tried installing it using **npm** as well as manually by cloning the git repo but still, no luck. I understand that you are calling a function `ansiToHtml()` in the function nodes but that does not seem to work for me. Do you have any idea how to fix this?

My node-red and node.js version info is as follows:

```auto
7 Jun 14:43:59 - [info] Node-RED version: v1.3.5
7 Jun 14:43:59 - [info] Node.js version: v12.22.0
7 Jun 14:43:59 - [info] Linux 5.10.17-v7l+ arm LE
7 Jun 14:43:59 - [info] Loading palette nodes
7 Jun 14:44:01 - [info] Dashboard version 2.28.2 started at /
7 Jun 14:44:01 - [info] Settings file : /home/pi/.node-red/settings.js
7 Jun 14:44:01 - [info] HTTP Static : /home/pi/.node-red/static
7 Jun 14:44:01 - [info] Context store : 'default' [module=memory]
7 Jun 14:44:01 - [info] User directory : /home/pi/.node-red
7 Jun 14:44:01 - [warn] Projects disabled : editorTheme.projects.enabled=false
7 Jun 14:44:01 - [info] Flows file : /home/pi/.node-red/flows_rss-01.json
7 Jun 14:44:02 - [info] Server now running at http://127.0.0.1:1880/admin/

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 June 2021 15:32 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/26 "2021-06-07T15:32:47Z")

</div>

Did you enable [function external modules](https://nodered.org/docs/user-guide/writing-functions#using-the-functionexternalmodules-option)?

You don't install that package into node-red node\_modules you use the "setup" tab on the function node to add the package.

---

<div class="post-metadata">

**Author:** ![abhilash-ingale](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/abhilash-ingale/32/41401_2.png) [@abhilash-ingale](https://discourse.nodered.org/u/abhilash-ingale)\
**Post date:** [7 June 2021 16:10 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/27 "2021-06-07T16:10:21Z")

</div>

I understand now that I had not configured the function node. However, I cannot see `functionExternalModules` in my settings.js file. As mentioned earlier, I am running node-red 1.3.5. Has the name changed by any chance? I am uploading my settings file as .txt for reference.

[settings.txt](https://discourse.nodered.org/uploads/short-url/yWOQ5OPLnA1b6NbJXdAgvdM0Ubs.txt) (12.9 KB)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 June 2021 17:16 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/28 "2021-06-07T17:16:18Z")

</div>

Just add `functionExternalModules: true` in the settings.

Be sure to add a comma before or after depending on where you add it.

---

<div class="post-metadata">

**Author:** ![abhilash-ingale](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/abhilash-ingale/32/41401_2.png) [@abhilash-ingale](https://discourse.nodered.org/u/abhilash-ingale)\
**Post date:** [7 June 2021 17:36 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/29 "2021-06-07T17:36:59Z")

</div>

Ok, now it works! Thank you for the help in debugging.

---

<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:** [21 June 2021 17:37 UTC](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905/30 "2021-06-21T17:37:37Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/where-can-i-find-or-enable-an-interactive-console-in-node-red/45905.md?page=1)
