Alternate-node-red-installer and pkg

Hello,
I have installed node-red using alternate-node-red-installer and created my flows that i want to package using pkg,
I have seen a topic that was closed talking about it but couldn't figure out what to do
Node-RED version: v3.0.2
Node.js version: v16.15.0
pkg version : 5.8.0

Here is what i added in my package.json
image

I don't know if it's the correct settings because I have all these warnings and errors appearing when running .exe file after the packaging

can you help please ?

The other thread that is referenced is here:

Not sure that ever got resolved and without further input, the thread auto-closed.

Well, the first thing to fix are the warnings. They all say the same thing and it points to the httpNodeRoot property in your settings.js - it is set to false which turns off the ability to use http-in nodes. Set it to an empty string instead.

The errors look like they come from you trying to use node.js modules in function nodes. The packager won't have picked those up and so your executable can't do anything when it comes to them. Move the require statements to the globals section of the settings.js file and make sure they are listed as dependencies in the userDir package.json file so that the packager includes them. Then adjust your function nodes to remove the references in setup and change the code to get a reference to the module from the global context.

e.g.

const fs = global.get('fs')
1 Like

Thank you so much for your help, it resolved all of the errors and warnings;
And everything works fine on my machine, but when I wanted to share the .exe file along with the UserDir file, it didn't want to start and access refused was written on terminal of another machine
Do you know why perhaps?

Can you paste the exact error from terminal?
and the command line to run the executable

I use pkg to compile an image for various platforms (not NR related)

the command line to run the executable is : node-red-master.exe --userDir ./data
error : access denied

And you're working in the directory that node-red-master.exe resides?
if so - is UAC/Defender/Firewall getting in the way? - Given its an executable from 'another location'?

Not sure what else to check, given this is not a "normal" way to run Node RED :sweat_smile:

1 Like

Have you run thr .pkg ?
I don't see you run the pkg module.
You need install the pkg module first.

Yeah :sweat_smile: i know it's not the usual way to run it
but i want to distribute my app to clients that's why this is required
anyway , yes i am working in the same directory as node-red-master.exe
maybe it's something to do with defender
(honestly I don't know)

yes the module is installed that's how I generated the executable file

Check if the executable is blocked in properties?

Sorry for the delayed response, everything works well now, the access denied error just disappeared after I restarted the machine.

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