Am I right in assuming if I have an already developed Node-RED application I can just replace the flows.json file with mine into the directory that gets created? Or is it usually better to develop after I've followed step 1?
If I use something like node-red-contrib-ui-media a folder called "ui-media" gets created to use your uploaded media. Should this work the same?
I'm currently using a folder in my Projects directory called "audio" to store some .wav files and I reference their location in some read-file nodes. Do I need to add them as dependencies in the package.json file? Are there any other locations that need to be aware of this?
In an effort to try other solutions as well and report on them, I have tried to follow the steps from this ReadMe GitHub - dceejay/node-red-project-starter: This is a template for a Node-RED project meant to be run in local mode but I ran into issues with require() not being supported. I followed some articles that say to change require() to import() but then I got an error that I can't use import outside of a module. The next solution I found said to add a line to my package.json to change type from "git" to "module" but this didn't help. Has anyone used this successfully? Is this option of packaging similar enough to the 'pkg' method discussed above? Any advantages?
@TotallyInformation I had not looked at this until now. If I understand correctly, your "alternative installer" and dceejay's "node-red-project-starter" are essentially trying to accomplish the same thing?
Once this is installed can I copy my 'flows', 'flows credentials', and any other files to the new folder structure, or would I need to export and import within the editor to make sure things get put in the proper places?
Can I install additional nodes from the palette manager, or would I need to use npm install?
Would I need to move the entire directory to the new Pi once I'm ready to deploy? Or would it be beneficial to still create an executable/binary?
Sorry for all the questions, I have a bad habit of asking too many questions before I get started on something when half of them could be answered if I just get started...
You need everything. However, there is one slight issue. If you set up on one platform and then move to a different one - e.g. PC to Raspberry Pi - you need to not copy over the node_modules folder because some of the installed packages won't work. They also tend to be massive and not worth copying anyway. Instead, copy everything except those folders and do an npm install in each of the master folder and the data folders (and the uibuilder folder if you are using that). The respective package.json files contain everything needed to reinstall the correct packages.
This sounds great. I want to rephrase my first question as it was kind of vague. Once I complete the install process, what is the best way to move an existing project to the standalone install? I.e. I have already completed a project using a standard Node-RED install with the projects feature, and I want to move it to the standalone setup?
Also, when I want to start a new project using the standalone setup, would I just copy the master directory to a new directory, and then change the flows? Or would starting the process over be the better option?
If you are copying to a similar platform (e.g. Wintel -> Wintel) you can go ahead and do a straight copy.
However, if you are doing it regularly, I would recommend creating a script. Details of that are going to depend on your platforms. I'd be happy to add some scripts to the alternate installer repo though if you can come up with a decent one. And happy to help if you have some more detail about the source/target platforms.
That sounds good and I appreciate you offering further help. For now most of my development work is being done on a Raspberry Pi 4B to be distributed to other Raspberry Pi's (not always Pi 4). I have a few projects that have been developed and run on Windows machines, but it is less rare that my deployment is on a Windows machine. I will look into scripting and try to come up with something, as this is something I will probably do fairly frequently.
If I have a project that requires other software outside of node-RED, (a popular combination is Node-RED, InfluxdB, and Grafana):
Is there a way to package those with this standalone/portable method? Could I just install those packages to the same directory?
Would another solution make more sense for that specific scenario such as Electron or Docker?
Also while we have been discussing, I have been working on the electron-node-red project from dceejay, and the default version is working.
Is there a way to expose the dashboard to another user on the network like standard node-RED, or is the dashboard only accessible on the host machine?
I am assuming this made a binary/executable that I'm running with the yarn start command, but I'm not seeing a file I can double-click to execute. What file(s) would I need to move to the deployment Pi to run the application?
I saw that, I left the random port alone, and used the developer tools to discover the assigned port number. I then used http://hostname:port/ui/#/0 in my address bar but I received a "site cannot be reached" message.
Also, I used merger.js to copy an existing Node-RED project. It is using the Projects feature from a standard Node-RED install. So the path was /home/pi/.node-red/projects/MyProject. After I ran another yarn && yarn dist. I then used yarn start and the application launches into the editor and says I have unknown node types. It appears all the nodes I installed via the palette manager have an issue. But in the palette manager from the electron app editor it shows they are installed. Do I need to manually install them using npm, or add them to the package-template.json file?
Can’t recall(on my phone on a train). I think it should try to merge your package.json with the template one to create an overall one and that needs to be installed by yarn before (or as part of) building it
I will try changing the port to be fixed and see if I can find the dashboard.
I'm not sure how it works but I've noticed that the package.json file in the projects folder doesn't have much and definitely doesn't have the additional nodes. The package.json file in the .node-red directory does list all the additional nodes I have installed. I will try adding the dependencies the package-template.json file in the electron install and see if that resolves it.
Like I mentioned earlier, what file(s) do I need to move to the deployment Pi to run the application? I realize I could create my own ".desktop" file with the yarn start /path/to/file command, but I'm assuming that shouldn't be necessary.
Must admit been a while since I tried building on pi. But you should be able to run yarn build (I think… as per read me) and it should create a .deb file you can install using dojo like any other Linux package
The read me says to use yarn dist. There is also an identifier to specify architecture. I have been getting an error when I build that seems to be targeting a x86 linux system. Maybe that is part of the issue. Can I specify ARM architecture? I sped past the error since the default application ran and seemed to work fine. But when I type yarn start I don't know what file it is telling to start. I don't see a .deb or any file that seems to be the "executable/binary" that runs. I've looked in the "build" and "dist" directories.
When I perform a yarn && yarn dist this is the error I am getting:
yarn run v1.22.19
warning ../../package.json: No license field
• electron-builder version=22.14.13 os=5.15.84-v7l+
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist/builder-effective-config.yaml
⨯ Unsupported arch arm failedTask=build stackTrace=Error: Unsupported arch arm
at Object.archFromString (/home/mtg/ExampleProject/electron-node-red/node_modules/builder-util/src/arch.ts:48:13)
at Object.computeArchToTargetNamesMap (/home/mtg/ExampleProject/electron-node-red/node_modules/app-builder-lib/src/targets/targetFactory.ts:30:24)
at Packager.doBuild (/home/mtg/ExampleProject/electron-node-red/node_modules/app-builder-lib/src/packager.ts:432:41)
at Object.executeFinally (/home/mtg/ExampleProject/electron-node-red/node_modules/builder-util/src/promise.ts:12:14)
at Packager._build (/home/mtg/ExampleProject/electron-node-red/node_modules/app-builder-lib/src/packager.ts:376:31)
at Packager.build (/home/mtg/ExampleProject/electron-node-red/node_modules/app-builder-lib/src/packager.ts:337:12)
at Object.executeFinally (/home/mtg/ExampleProject/electron-node-red/node_modules/builder-util/src/promise.ts:12:14)
error Command failed with exit code 1.
Is this saying that the ARM architecture is not supported?
ah right yes - there will probably need to be changes in the overall package.json - build - linux section. I think it used to build for armv7l - but as I said I've not used it for a while so some of he options may have changed / need updating.
It appears to include the right architecture. Is there somewhere else it might need to be updated? I have read some threads that this is an issue with electron-builder and the Pi4. Most people recommend adding modifiers to the build command such as electron-builder --dir --armv7l --linux deb not sure how I could apply that here?
Also, I added the additional modules to the dependencies section of the package-template.json file and rebuilt via yarn && yarn dist, but there was no change. Even stranger is that the dashboard should have been installed because the example project uses it, but it is also showing as missing. Where else would I need to reference them?
I realize this thread has gotten really long but I felt that all this information was pertinent to the topic of executables. But if I need to open a new thread specifically about the issues I'm having with the electron-node-red project I would be happy to. I wish I could mark multiple solutions because there has been some really good information shared.
I'm circling back around to this topic and decided to start from the top and try each solution. I deleted my previous comment as I rushed to write a post rather than explore
I followed @marcus-j-davies instructions and I would like to make a few notes on what I needed to do on a fresh install of rpi os (64-bit).
sudo apt update && sudo apt upgrade
Installed LTS version of Nodejs (comes with npm)
npm install node-red
npm install node-red-dashboard
sudo npm install -g pkg
pkg . -t host
This all worked well and created my binary. I was able to run this binary and a normal instance of node-red ran and I was able to create flows and deploy as usual.
Then I tried to compile for a Windows machine. The only command I got to work was: pkg . -t win-x64
This created a .exe file, I moved it to my PC (which already has the global version of Node-RED installed via the official installer instructions), and when I launched the .exe it brought up Node-RED and launched my previous project that I had been working on. I plan to test on a PC that doesn't have Node-RED installed to see how it behaves.
The system I've been using to follow all of the steps listed is a rpi4 running rpi os 64-bit. I tried making an executable for a rpi0 running rpi os 32-bit, but I was unsuccessful. After looking at the github page for pkg I found: pkg . -t linux-armv6 but I received the error > Error! Unknown token 'armv6' in 'linux-armv6 I tried this with armv7 just for kicks and it gets a lot farther into the process but ultimately fails as well.
I read something when googling this issue that I might need an older version of pkg that still supports armv6. Can anyone suggest what I might try to get an executable for a rpi0?
How does the exe actually start things? I'm assuming it uses the npm start script? If so, you might want to adjust the script to use a local userDir folder instead of the default one? Check out my alternate installer repo for some ideas.
For Windows, I use alternate installer to create a folder with sub-folder packages that can be deployed on other systems. You need to install node.js on the PC then copy the package to a location of your choice. I use nssm to create service. Typically I have the main instance and I can spawn other instances by using symbolic link folders to the base node install. It's not as simple as an install and your done. It's more like install node.js, install node red alternate installer, then install node-red on your folder you want to be the model you want to copy to other pc's. On your other pc, install node.js, then copy to your main folder, configure your starting script, usually a command file. Then configure nssm for creating services to run your instances. On your destination pc, you can have as many instances you want. So the source server hosting your first installed package serves as a copy point to literally paste to any pc to create other instances on that destination server.