Help with userDir option needed

244 views
Skip to first unread message

Claudiu O

unread,
Aug 6, 2014, 10:29:57 AM8/6/14
to node...@googlegroups.com
I followed the steps in the Running Nodered on Rasp Pi unattended post and everything went great - thanks a lot to everyone posting steps/scripts: you guys are awesome! There is only one thing: node-red got installed under usr/local/lib/node_modules/node-red so the flows are saved in that location. I would like to have the flows in pi's home directory so I thought I could use the userDir option but I can't get it to work (I guess I can redo the installation of node-red and not install it with -g but if userDir would work as I thought it should, there is no need for that).

I tried all kinds of combinations: -userDir /home/pi/flows, -userDir=/home/pi/flows, -userDir /home/pi/flows/, --userDir /home/pi/flows and many others but no matter what I try I get:

[red] Loading flows : /home/pi/flows/
[red] Error loading flows : Error: EISDIR, read

I even created a file flows_raspberrypi.json in that dir and still no success. I am obviously doing something wrong. Do I need to copy more files in that dir, like settings.js or create other subdirs or something else?

I'd appreciate any help I can get. Thank you!

Nicholas O'Leary

unread,
Aug 6, 2014, 10:35:06 AM8/6/14
to node...@googlegroups.com
Hi,

you set userDir in your settings.js, not on the command line.

Nick




--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Claudiu O

unread,
Aug 6, 2014, 10:51:43 AM8/6/14
to node...@googlegroups.com
Only if I paid more attention to the configuration page...

Thanks a lot for your help!

   claudiu

The ThingBox

unread,
Mar 23, 2015, 1:21:37 PM3/23/15
to node...@googlegroups.com

And how can I have access to the userdir from a function node?

They are set as:

var settings_nodered = {
httpAdminRoot:"/",
httpNodeRoot: "/api/",
userDir: "/root/userdir/",
flowFile: "/root/userdir/flows/local/flows.json",
verbose: true,
flowFilePretty: true,
functionGlobalContext: {
wpi: require('node-red/node_modules/wiring-pi')
,settings: settings_ttb
}
};

// Initialise the runtime with a server and settings
RED.init(server,settings_nodered);

Nicholas O'Leary

unread,
Mar 23, 2015, 1:28:22 PM3/23/15
to Node-RED Mailing LIst
Hi,

If you want to expose something to the Function node, you must place it under functionGlobalContext.

For example:


var userDir = "/root/userdir/";
var settings_nodered = {
httpAdminRoot:"/",
httpNodeRoot: "/api/",
userDir: userDir,
flowFile: "/root/userdir/flows/local/flows.json",
verbose: true,
flowFilePretty: true,
functionGlobalContext: {
wpi: require('node-red/node_modules/wiring-pi')
,settings: settings_ttb,
                userDir: userDir
}
};


And then reference it as `context.global.userDir` in the Function node.

Nick

--
Reply all
Reply to author
Forward
0 new messages