# Calling node-red flows from node app

**URL:** <https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667>\
**Category:** General\
**Created:** [29 May 2019 11:38 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667 "2019-05-29T11:38:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [29 May 2019 11:38 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667/1 "2019-05-29T11:38:10Z")

</div>

i found problem on embadding my node-red flow on my nodejs app.  
here's my setting

> // Create a server  
> var server\_nr = http.createServer(app);
> 
> // Create the settings object - see default settings.js file for other options  
> var settings = {  
> httpAdminRoot:"/api/ui/#!/1",  
> httpNodeRoot: "/api",  
> userDir:"C:\Users\len\.node-red",  
> functionGlobalContext: { } // enables global context  
> };
> 
> // Initialise the runtime with a server and settings  
> RED.init(server\_nr,settings);
> 
> // Serve the editor UI from /red  
> app.use(settings.httpAdminRoot,RED.httpAdmin);
> 
> // Serve the http nodes UI from /api  
> app.use(settings.httpNodeRoot,RED.httpNode);

> const port = process.env.PORT || 5000;
> 
> server = app.listen( port, function(){
> 
> // Launch the demo in the browser  
> opn("[http://localhost](http://localhost):" + port +"/api/ui/#!/1" );  
> // Start the runtime
> 
> })  
> RED.start();

i always go this error app.min.js:148 ReferenceError: io is not defined  
and a blank page.  
any help please!!

---

<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:** [29 May 2019 11:42 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667/2 "2019-05-29T11:42:46Z")

</div>

well the error is unreadable ... so... hard to guess what it says...  
but I'm going to start with the `\` in your userDir path need to be escaped so `\\` instead of `\` or use `/` instead

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [29 May 2019 11:52 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667/3 "2019-05-29T11:52:50Z")

</div>

no, none of them works .. is it a matter of port or server !!?

---

<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:** [29 May 2019 11:55 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667/4 "2019-05-29T11:55:50Z")

</div>

> [@hathemi](#):
>
> opn(

opn ? Is that some function you have defined ? (Don't forget this is running server side so won't open a browser)

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [29 May 2019 12:01 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667/5 "2019-05-29T12:01:26Z")

</div>

`const opn = require("opn");`  
Sorry but i don't really get your point. what's the problem with that !?

---

<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:** [29 May 2019 12:34 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667/6 "2019-05-29T12:34:14Z")

</div>

nothing apart from not being in the code you shared (I'm not a mind reader).  
And also being a deprecated package...  
carry on.

---

<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:** [29 May 2019 12:34 UTC](https://discourse.nodered.org/t/calling-node-red-flows-from-node-app/11667/7 "2019-05-29T12:34:45Z")

</div>

> [@hathemi](#):
>
> Sorry but i don't really get your point. what's the problem with that !?

The code you shared above does not include the `require("opn")` statement - so it was perfectly reasonable to question the `opn(..)` call.

`httpAdminRoot:"/api/ui/#!/1",`

That is not a valid value. This is meant to be the path the editor UI is served from. It must not have a `#` in it/
