Node RED v4 : Single File Executable

Reading the github readme I was under the impression that flow can't be modified (even at runtime)

You're tasked by your client to design a dashboard that takes input from a user, and it gets processed with your magic sauce/IP. There will be some level of code (or all of it), that you don't want to reveal or be messed with.

Perhaps this can be altered in some way, I'm not that familiar with core node-red procedures, otherwise maybe mention this in readme, so someone would not be under the same impressions and want to deploy this somewhere thinking no one can alter the flow.

Putting this aside, very cool project!

1 Like

it does note it...

If a flow is not embedded, the SFE will create a directory called NRUserDir on startup if it's not already been created. This allows you to deploy the executable with a modifiable flow (but note: this also allows you to view the flow code)

but yes - I should make it more clear - thanks for the feedback :+1:

If a flow is not embedded, the SFE will create a directory called NRUserDir on startup if it's not already been created. This allows you to deploy the executable with a modifiable flow (but note: this also allows you to view the flow code)

But I did embed the flow.

The final executable will contain an embedded file system, which is read only. Therefore, if you do not block access to the Editor (disableEditor ) and try to deploy (or install Nodes) after, it will fail.

It's true I can't seem to install new nodes, but I can deploy the changes and also disabling the panel does not prevent me to add new ones or add flows - all that can be done through UI or action panel which is available.

I'm not criticizing, just seems that readme is a bit confusing.

Don't worry - im all ears :smiley:

I guess it should re-worded as.


Providing you embed a flow, and disable the editor : disableEditor: true - the flow becomes difficult to reverse engineer - given its embedded and the editor is fully disabled


I'm happy for a PR for any read me changes :slightly_smiling_face:

Yea I didn't set this: disableEditor: true - now this is the flow I was expecting!

And because I never disabled editor before in node-red I thought this was on by default, seeing those disabled panels and deploy button (that don't do anything btw except confuse people like me :smiley: )

All good and confusion resolved.

1 Like

The recommended approach is highlighted



But yes, I agree - should emphasise this more

1 Like

Thats is completely out of my skill set, but I've tried to run this application via .bat file and then startup dashboard.

START node-red-sfe.exe

doesn't work. there are no installed nodes available:


but when I run it by double clicking it is fine:
image

any ideas how to run it by .bat file?

I'm not a windows user...
But I think you need to set the working directory in the bat file

Try this..

cd /d %~dp0
node-red-sfe.exe

I think by default, windows doesn't run the bat file, from the current directory it resides (or something like that)

I created a PR of what @KarolisL requested, to open browser automatically on NR-SFE start if editor is not disabled.

2 Likes

Amazing!

I'll get it merged soon.

I want to bump yao-pkg also (where the magic happens) - as I think it has some fixes with later node versions under windows.

Sure, and feel free to put it in build configuration if you think it should be optional. I didn't want to put in in settings.js as that is nr specific.

Hello, my initial request was to add parameter to settings.js file:

	/* Change me */
	credentialSecret: '#########################',

	/* This should be set to true, JUST BEFORE compiling to an SFE */
	/* But it will be ignored (forcibly set to false) during the development stage */
	disableEditor: false,
    autostartDashboard: false, <- new parameter to autostart dashboard

but your PR changes seems to be easy to modify for my needs:

 const url = `http://127.0.0.1:${nrSettings.uiPort}/dashboard`; 

am I right?

I’ll get this merged tomorrow,

And will look to add the ability to auto start (along with a custom URL)

I want to try and do it without using settings.js (as that is for Node RED only)

I’ll have a think

One thought I had - if a file of “AUTOSTART” is found, it will launch the URL inside of that file

1 Like

Ok @KarolisL

Using the contribution from @ziga.
I have now merged some changes, with the following effect.

  • if a file named AUTOLOAD (no file extension) is found in the same location as the executable, it will load up the URL inside of it. (regardless of disableEditor, or mode)
    • if begins with / - will append the URL to the admin endpoint (example : /dashboard)
    • If has an absolute URL (http://...) - will load up that URL.

See the table below

Mode disableEditor AUTOLOAD Found Auto Loaded URL Editor Possible
Design Time N/A N/A Editor YES
Run Time TRUE/FALSE YES From File IF ALLOWED
Run Time TRUE/FALSE NO ————— IF ALLOWED

Have also bumped a few dependencies

Please do let me know how this gets on - I have done minimal testing.

2 Likes

Looks awesome,

works exactly as expected!

1 Like

One more request:
in the same manner that you have done AUTOLOAD,
would it be possible to copy/paste external file folder that are in "Node-RED-SFE-main" directory?

If directory "files" (or whatever) exists copy it with all contents to build/dist?

=>

Thanks in advance!

Hi @KarolisL

What’s the use case?
I ask - as you can already set HTTP Static for this type of setup.

See the last point here : GitHub - marcus-j-davies/Node-RED-SFE: A Single File Executable framework for Node-RED

You can just modify the build script if you wanted to move files to the output.

Thanks for a reply, my use case is that I plan to distribute SFE with external files which engineer has to modify to his use case. These files are basically templates... I just use local filesystem

Every time I create a new build - dist folder is cleared. "files" folder is removed so I just have to copy/paste from develop environment

honestly, didn't work with httpStatic before, I though it was a way to store your images and etc, for dashboard purposes

Ok got it.

I’ll add the ability to move a folder called ExternalFiles to the dist folder?

Looks good to me,
I (DeepSeek) wrote a shell script

# Check if settings.js exists
if (-Not (Test-Path -Path "./settings.js")) {
    Write-Host "Run script in Node-RED-SFE-main folder"
    pause
    exit
}

# Check if node_modules folder exists
if (-Not (Test-Path -Path "./node_modules")) {
    $installNPM = Read-Host "node_modules folder not found. Can I run 'npm install'? (yes/no)"
    if ($installNPM -eq "yes") {
        npm install
    } else {
        exit
    }
}

# Provide menu options
function Show-Menu {
    Write-Host "1. npm run-script develop"
    Write-Host "2. npm run-script package"
    Write-Host "3. Exit"
}

do {
    Show-Menu
    $choice = Read-Host "Choose an option (1-3)"
    switch ($choice) {
        1 {
            npm run-script develop
        }
        2 {
            npm run-script build
            npm run-script package

            # Check if "files" folder exists and copy it to ./build/dist
            if (Test-Path -Path "./files") {
                $destination = "./build/dist"
                if (-Not (Test-Path -Path $destination)) {
                    New-Item -ItemType Directory -Path $destination | Out-Null
                }
                Copy-Item -Path "./files" -Destination $destination -Recurse -Force
                Write-Host "'files' folder copied to $destination"
            } else {
                Write-Host "'files' folder not found, skipping copy."
            }
        }
        3 {
            exit
        }
        default {
            Write-Host "Invalid choice, please select a valid option."
        }
    }
} while ($true)

which helps to automate things a bit. Maybe it will be useful for somebody in the future