Can I package whole nodered project using pkg node?

Hi nodered experts,

I successfully created a project on nodered using an offline installer by TotallyInformation. It means I can run nodered projects independently.

Now I want those "nodereds" to run on a single executable file (each nodered project have their own .exe file) without installing node.js on a the target computer.

I found this node-pkg

But I am not just sure how am I going to implement this in my nodered project folder.

I want to retain all my user interface to be in the browser when I run the executable file created using that pkg.

The purpose of building in in one package is.

  1. So that the user cannot edit the code in nodered
  2. No need to install the nodejs in the target computer.

Thank you very much.

Regards,
Henjoe

Hi, I've not tried using pkg so it would interesting if you found out :slight_smile:
Normally I use electron - see GitHub - dceejay/electron-node-red: Electron Node-RED template - but I must admit I haven't really been maintaining it for a while so it may be well behind the curve of latest electron capability.
The idea of my app is generally only expose the dashboard view - but the editor can be enabled if needed - but that really wasn't the idea... Of course although it i a "single app" it is still really just an embedded browser instance and node engine so anyone skilled could extract the underlying flow quite easily if they knew what they were doing and where to look. But it does make it easy to install and stops casual messing around.

Thanks @dceejay for prompt and informative response.

Perhaps, I am still trying to do it and searching for it on how am I going to package it into "one" executable file.

Hoping for someone here in our community able to do it :slight_smile:
Thanks and best regards!
Henjoe

Dave, maybe it would be easier to maintain a build script then people could do it themselves?

Have you had a go? Using my alternate install should give you the kind of config and folder structure you need to get started.

However, this seems problematic:

However your code may have require(variable) calls (so called non-literal argument to require ) or use non-javascript files (for example views, css, images etc).

Which implies that there would a LOT of work to do in order to identify all of the variable dependencies. uibuilder for example has many cases where it constructs a path to a package.json file and then imports it.

But, it would be worth just having a go and see if it works without too much config, you never know.

Hi @TotallyInformation I actually managed it using pkg.
by adding this package.json
image

Then run "pkg ."

It has 3 outputs for different OS:

then I can use the .exe file on my command prompt, I just need to put --userDir arguments.
image

And it works just like "npm start" on your alternate-installer.

The advantage of doing this is you just have to copy the node-red-master-win.exe to any other computer along with the "data" folder. and you can run node-red on any computer :slight_smile:
Without installing nodejs.

Thanks!

Regards,
Henjoe

6 Likes

Well the readme starts with a section on how to wrap up an existing project - so there is that...

The downside, of course, is that you now have to regularly update, rebuild and redistribute it.

Much better, where possible, to have a server-based service with users accessing it via only a browser. In our work environment, our standards say that "thick clients" are not permitted without special permission. This is due to the cost of maintaining them. If you do have to have a thick client (perhaps because your users have to work sometimes without network access), there must be a built-in update mechanism. With a node.js based application, this is really hard to monitor and assure since a typical node.js app has many dependent packages any of which may have serious security or other issues as might node.js itself.

In its native form, it is relatively easy to assure that node.js, Node-RED and all of the other components are up-to-date.

1 Like

There are also now well developed built in update mechanisms in electron ( as used by vs-code etc) . ( though not built into my example app ).

That's good news. I last used pkg for a video streaming project (unrelated to node-red) about 3 years ago. Previously, they had issues packaging all of the files and any c++ node addons, but it had worked good enough for me. It seems they have come a long way if it can package something as complicated as node-red.

I TotallyAgree with your point @TotallyInformation :smiley:

In my case, I just don't want the users to update anything on the node-red project :slight_smile:
All programming, modules and etc are already done, and I just want them to use it "one-click" away :slight_smile:

Regards,
Henjoe

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