# Node File does not work on Windows 10

**URL:** <https://discourse.nodered.org/t/node-file-does-not-work-on-windows-10/48521>\
**Category:** General\
**Created:** [17 July 2021 12:15 UTC](https://discourse.nodered.org/t/node-file-does-not-work-on-windows-10/48521 "2021-07-17T12:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roman](https://avatars.discourse-cdn.com/v4/letter/r/ed8c4c/32.png) [@Roman](https://discourse.nodered.org/u/Roman)\
**Post date:** [17 July 2021 12:15 UTC](https://discourse.nodered.org/t/node-file-does-not-work-on-windows-10/48521/1 "2021-07-17T12:15:43Z")

</div>

Hi!  
I'm trying to append file with text on local file system.  
Here is a duplicate, but there is no solution: [File node not working on windows](https://discourse.nodered.org/t/file-node-not-working-on-windows/28204)

Here's my first try. I wrote file name in property filename of node file:

```auto
[{"id":"80d649c2.f66f58","type":"inject","z":"3aaeeceb.d5ae64","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":100,"wires":[["84711ac0.43a1f8"]]},{"id":"84711ac0.43a1f8","type":"function","z":"3aaeeceb.d5ae64","name":"format DateTime","func":"return new Date(msg.payload);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":100,"wires":[["761c3f2a.4c002","a936aca1.2db3a"]]},{"id":"668c5ac4.ef8b34","type":"debug","z":"3aaeeceb.d5ae64","name":"file node output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":100,"wires":[]},{"id":"761c3f2a.4c002","type":"file","z":"3aaeeceb.d5ae64","name":"","filename":"D:\\test\\nodered.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":610,"y":100,"wires":[["668c5ac4.ef8b34"]]},{"id":"a936aca1.2db3a","type":"debug","z":"3aaeeceb.d5ae64","name":"before writing into file","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":360,"y":160,"wires":[]},{"id":"3fe82c65.0b0894","type":"catch","z":"3aaeeceb.d5ae64","name":"","scope":null,"uncaught":false,"x":640,"y":140,"wires":[["db53f5db.f4e7b8"]]},{"id":"db53f5db.f4e7b8","type":"debug","z":"3aaeeceb.d5ae64","name":"catch error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":140,"wires":[]}]

```

Also I tried to write path as `D:\\test\\nodered.txt` and `D:/test/nodered.txt`, but it didn't work. Catch node didn't catch anything.  
Why doesn't it work?

My second try was without setting filename property in node, but in msg that file node receive. Here it is:

```auto
[{"id":"80d649c2.f66f58","type":"inject","z":"3aaeeceb.d5ae64","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":180,"wires":[["84711ac0.43a1f8"]]},{"id":"84711ac0.43a1f8","type":"function","z":"3aaeeceb.d5ae64","name":"add filename to msg","func":"return {\n payload: new Date(msg.payload),\n filename: \"D:\\\\test\\\\nodered.txt\",\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":180,"wires":[["761c3f2a.4c002","a936aca1.2db3a"]]},{"id":"668c5ac4.ef8b34","type":"debug","z":"3aaeeceb.d5ae64","name":"file node output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":960,"y":180,"wires":[]},{"id":"761c3f2a.4c002","type":"file","z":"3aaeeceb.d5ae64","name":"","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":770,"y":180,"wires":[["668c5ac4.ef8b34"]]},{"id":"a936aca1.2db3a","type":"debug","z":"3aaeeceb.d5ae64","name":"before writing into file","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":480,"y":240,"wires":[]},{"id":"3fe82c65.0b0894","type":"catch","z":"3aaeeceb.d5ae64","name":"","scope":null,"uncaught":false,"x":760,"y":220,"wires":[["db53f5db.f4e7b8"]]},{"id":"db53f5db.f4e7b8","type":"debug","z":"3aaeeceb.d5ae64","name":"catch error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":220,"wires":[]}]

```

And it works. Why?

---

<div class="post-metadata">

**Author:** ![Roman](https://avatars.discourse-cdn.com/v4/letter/r/ed8c4c/32.png) [@Roman](https://discourse.nodered.org/u/Roman)\
**Post date:** [17 July 2021 13:35 UTC](https://discourse.nodered.org/t/node-file-does-not-work-on-windows-10/48521/2 "2021-07-17T13:35:46Z")

</div>

File node didn't work because I was passing to it invalid message. File node write text to file only if message has property payload. And I was passing message without this property.  
Here is working code(change in node function):

```auto
[{"id":"80d649c2.f66f58","type":"inject","z":"3aaeeceb.d5ae64","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":200,"wires":[["84711ac0.43a1f8"]]},{"id":"84711ac0.43a1f8","type":"function","z":"3aaeeceb.d5ae64","name":"add filename to msg","func":"return {\n payload: new Date(msg.payload),\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":200,"wires":[["761c3f2a.4c002","a936aca1.2db3a"]]},{"id":"668c5ac4.ef8b34","type":"debug","z":"3aaeeceb.d5ae64","name":"file node output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":940,"y":200,"wires":[]},{"id":"761c3f2a.4c002","type":"file","z":"3aaeeceb.d5ae64","name":"","filename":"D:\\test\\nodered.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":730,"y":200,"wires":[["668c5ac4.ef8b34"]]},{"id":"a936aca1.2db3a","type":"debug","z":"3aaeeceb.d5ae64","name":"before writing into file","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":460,"y":260,"wires":[]},{"id":"3fe82c65.0b0894","type":"catch","z":"3aaeeceb.d5ae64","name":"","scope":null,"uncaught":false,"x":740,"y":240,"wires":[["db53f5db.f4e7b8"]]},{"id":"db53f5db.f4e7b8","type":"debug","z":"3aaeeceb.d5ae64","name":"catch error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":240,"wires":[]}]

```

---

<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:** [31 July 2021 13:35 UTC](https://discourse.nodered.org/t/node-file-does-not-work-on-windows-10/48521/3 "2021-07-31T13:35:50Z")

</div>

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