# How to get the path of nodered folder

**URL:** <https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362>\
**Category:** General\
**Created:** [11 May 2023 17:27 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362 "2023-05-11T17:27:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marchal-web](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marchal-web/32/66937_2.png) [@Marchal-web](https://discourse.nodered.org/u/Marchal-web)\
**Post date:** [11 May 2023 17:27 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/1 "2023-05-11T17:27:21Z")

</div>

Hello all,  
I would like to get the the path of where is running nodered, how I can do that ?  
The current path of the folder is "/home/toto/.nodered". How I can get this path in the flow?  
Thanks

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [11 May 2023 17:33 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/2 "2023-05-11T17:33:11Z")

</div>

```auto
msg.payload = `${os.homedir()}/.nodered`;

return msg;

```

That should work in a function node. may have to import os module in setup tab of function node

or just import this  
`[{"id":"feba76606996723c","type":"function","z":"9aee8eeac20f9015","name":"os.homedir()","func":"msg.payload = `${os.homedir()}/.nodered`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"os","module":"os"}],"x":1710,"y":840,"wires":[["e1a68d10b9905b8b"]],"info":"// nrlint function-eslint:off\n"}]`

---

<div class="post-metadata">

**Author:** ![Marchal-web](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marchal-web/32/66937_2.png) [@Marchal-web](https://discourse.nodered.org/u/Marchal-web)\
**Post date:** [11 May 2023 17:38 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/3 "2023-05-11T17:38:04Z")

</div>

Thanks HaroldPetersInskipp,  
That makes it

---

<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:** [11 May 2023 20:08 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/4 "2023-05-11T20:08:50Z")

</div>

Note though, that this is not a general solution. It will work if node red is installed in the conventional manner, but may not work if the install is not the conventional one. For example, I run multiple instances of node red on one machine, the folders it is configured in are /home/user/.node-red-1880, /home/user/.node-red-1881 etc. Also it does not work if node red is a Docker install.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [11 May 2023 20:16 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/5 "2023-05-11T20:16:20Z")

</div>

Yeah, I had eventually run into that as well and my solution was to detect the OS first and then run a command in an exec node like this:

```auto
[{"id":"aafa49e090633de4","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"1b55b9fac53c0d3b","type":"exec","z":"aafa49e090633de4","command":"echo %cd%","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"pwd windows","x":610,"y":180,"wires":[["8066f1de239712fd"],[],[]]},{"id":"44c6f62fbc5fb7ed","type":"exec","z":"aafa49e090633de4","command":"pwd","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"pwd unix","x":600,"y":120,"wires":[["39efab045ccc5d11"],[],[]]},{"id":"546c70d79ade85c2","type":"function","z":"aafa49e090633de4","name":"check os","func":"msg.payload = msg.operatingSystem.name[0].toLowerCase();\nif (msg.payload === \"d\") {\n node.send([{ \"payload\": \"\" }, null, null]);\n} else if (msg.payload === \"l\") {\n node.send([null, { \"payload\": \"\" }, null]);\n} else if (msg.payload === \"w\") {\n node.send([null, null, { \"payload\": \"\" }]);\n};","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":140,"wires":[["44c6f62fbc5fb7ed"],["44c6f62fbc5fb7ed"],["1b55b9fac53c0d3b"]],"outputLabels":["mac","linux","windows"]},{"id":"f92f05779dd953af","type":"function","z":"aafa49e090633de4","name":"os npm module","func":"// info about the current user\nmsg.user = os.userInfo();\n\n// returns the system uptime\nmsg.uptime = {\n days: (os.uptime() / 86400).toFixed(2),\n hours: (os.uptime() / 3600).toFixed(2),\n minutes: (os.uptime() / 60).toFixed(2),\n seconds: os.uptime().toFixed(2),\n};\n\n// info about the operating system\nmsg.operatingSystem = {\n name: os.type(),\n release: os.release(),\n totalMem: `${parseFloat((os.totalmem() / Math.pow(1024, 3)).toFixed(2))}GB`,\n freeMem: `${parseFloat((os.freemem() / Math.pow(1024, 3)).toFixed(2))}GB`,\n architecture: os.arch(),\n homeDir: os.homedir(),\n tempDir: os.tmpdir(),\n networkInt: os.networkInterfaces(),\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"os","module":"os"}],"x":260,"y":140,"wires":[["546c70d79ade85c2"]],"info":"// nrlint function-eslint:off\n"},{"id":"5d2100058e88d46a","type":"inject","z":"aafa49e090633de4","name":"run","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.2","topic":"","payload":"","payloadType":"str","x":110,"y":140,"wires":[["f92f05779dd953af"]]},{"id":"8066f1de239712fd","type":"split","z":"aafa49e090633de4","name":"","splt":"\\","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":790,"y":180,"wires":[["91b6e330281f31b7"]]},{"id":"91b6e330281f31b7","type":"switch","z":"aafa49e090633de4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"index","v":"0","vt":"num","v2":"2","v2t":"num"}],"checkall":"true","repair":false,"outputs":1,"x":910,"y":180,"wires":[["fb71132b1f1fea39"]]},{"id":"fb71132b1f1fea39","type":"join","z":"aafa49e090633de4","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"/","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1030,"y":180,"wires":[["39efab045ccc5d11"]]},{"id":"39efab045ccc5d11","type":"string","z":"aafa49e090633de4","name":"","methods":[{"name":"collapseWhitespace","params":[]},{"name":"ensureRight","params":[{"type":"str","value":"/.node-red"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1170,"y":140,"wires":[["06171673b5b60ff7"]]},{"id":"06171673b5b60ff7","type":"debug","z":"aafa49e090633de4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1290,"y":140,"wires":[]}]

```

---

<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:** [12 May 2023 08:03 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/6 "2023-05-12T08:03:49Z")

</div>

Similarly, `pwd` doesn't tell you where node red is running from (is where the flows file is). They could be different.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [12 May 2023 14:54 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/7 "2023-05-12T14:54:24Z")

</div>

Maybe a search utility after determining OS? Unfortunately, I'm not familiar enough with the options available to get much further at that point.

---

<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:** [12 May 2023 15:03 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/8 "2023-05-12T15:03:41Z")

</div>

I am pretty sure there is an api call to get the location of the flows file, though I don't know what it is.

---

<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:** [11 July 2023 15:04 UTC](https://discourse.nodered.org/t/how-to-get-the-path-of-nodered-folder/78362/9 "2023-07-11T15:04:24Z")

</div>

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