Error using "node-red-contrib-ui-media" under Windows 10

Hi All
I'm fairly new to node-red and have always used it on my Raspberry PI which has worked well for my purposes.
Recently I have need to use it on a more powerful machine running Windows 10, however things that worked on Linux with zero effort from me no longer work on Windows. The error below in particular has me stumped.

I've installed the "node-red-contrib-ui-media" to display images within the dashboard, however as soon as I try add files via the "media" node I node-red crashes and I get the below error.
I've tried using the error catch node and debug node, but it still crashes, then I would need to delete the media node to get it to stop crashing.

As mentioned, I never had this issue running Rasbian or Ubuntu, and I am unsure how to resolve this under Windows 10. I've seen mention of possibly having to change root or user directories via the settings.js file. But it appears I am shooting in the dark and so far have had no luck

It is a fresh install of Windows and I installed Node-Red following the guide on this site.

Any assistance would be greatly appreciated.

7 Jul 21:57:44 - [info] Starting flows
7 Jul 21:57:44 - [info] Started flows
8 Jul 09:58:43 - [red] Uncaught Exception:
8 Jul 09:58:43 - TypeError: path must be absolute or specify root to res.sendFile
at ServerResponse.sendFile (C:\Users\abcd\AppData\Roaming\npm\node_modules\node-red\node_modules\express\lib\response.js:425:11)
at C:\Users\abcd.node-red\node_modules\node-red-contrib-ui-media\ui_media.js:288:17
at FSReqCallback.oncomplete (fs.js:155:23)
PS C:\Windows\system32>

My guess is that the node was authored by someone with no cross-platform experience and they've not taken into account the differences between Windows and Linux.

If you are specifying file locations, try using / instead of \ - that is accepted by Windows and will sometimes get around lack of accommodation in the code.

Otherwise, you will need to raise an issue against that node I'm afraid unless you want to dig into the code yourself.

Furthermore, the creator of the node has forgone to add error handling and proper catching of errors around parts that deal with user input and the file system, points that could cause errors if the user were to make a small mistake in their writing. Not catching these errors means node-red can’t properly recover from the error, and it crashes to it can restart and recover that way. Beyond the need for windows support to be added to the node, improved error handling might even take priority, as it should tell you what went wrong/what you might have done wrong rather than taking down the whole program.

According to this that bug was fixed over a year ago. Are you using the latest version (1.2.0). Look in Manage Palette to check.

Different issue. This is caused by fs.access checking for the path to exist/be in range, and if so prepend the path with C: when on win32 platforms, and "hoping it just works" by then passing that path forward to Express' serveFile call, which appears to have other requirement for what file paths should look like than what fs.access is considering valid. As everything is just wrapped in if/else calls that check for reported errors, rather than a try/catch block around such calls, it takes down the Node-RED server.

OK, but after that it was apparently running ok on Windows, for some users at least. So it is not a fundamental problem that means it won't run on Windows.

Even so, I think the only solution is to submit an issue on the node.

I agree with the need to report it on the node's page.

But to my understanding, the above error means that the path passed to sendFile says it must be absolute. Since they don't specify a root in the call, the user inserting a path in the media node will have to use an absolute path for it to work properly. fs.access does not have that same absolute path requirement, and it might be worth taking a look at the note beneath it:

The "Read (NOT RECOMMENDED)" example put below it could have been coming from the code of this node almost directly.

Thank You all for your feedback, I have submitted the issue, though I see it was submitted some time ago and resolved with windows 8 and Node version 1.1.3, perhaps it has resurfaced under windows 10 and version 1.2.0

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