@TotallyInformation - note that the referenced page says (as root) - so you can't just use an exec as that would be a privilege escalation. You need to either run the whole of Node-RED as root and then use exec as you said - which is probably a bad idea as no doubt the next thing will be to connect this to the internet so it can be remotely controlled. Or to write (outside of Node-RED) a wrapper for those commands that exposes them in user-space in a slightly safer manner. Several examples exist for Pi - eg https://www.raspberrypi.org/forums/viewtopic.php?p=131069&sid=88282aaa50634ad7db83c3965625c033#p131069
run the command ls -la /sys/class/gpio you may need to do that for the sub-folders too. Let us know what the output is. It may be that they are owned by root/root which wont help. But they might be owned by root/wheel - in which case you can simply add the user id running Node-RED to the "wheel" group.
Replacing <userid> with the userid that is running Node-RED. Sorry, not sure if you then have to log out and back in for the user to actually pick up the group (assuming you are logged in with the same account).
Also note that the /sys/class/gpio actually are linked back to /sys/devices and you will need to go and change ownership on those as well.
This avoids the need for you have to install and run Node-RED as root which is rather more secure. Also note though that you are opening up control of your GPIO ports to that user - you will want to make sure that you are using a decent password (or cert-based login) and make sure that if you are exposing Node-RED or other endpoints to the Internet that you have properly secured everything.
Now the problem is solved, when we run node-red or any other snap(like in any containerized environment like docker or snap..) we have to do some configuration to the application to communicate with host network or env. So ,in case of node-red we have to create interface between snap and the gpio slot.
command to be used: snap interface gpio to list available GPIO slots in the system.
Use snap connect snap:plug snap:slot to connect to the gpio slot.
ex in my case it is snap connect node-red:gpio caracalla:gpa-sku-gpio0