I've been successful in entering a global function in settings.js under functionGlobalContext: {}. So far I have not been able to create a global variable in settings.js; that node.js is happy with. Where do you put it and how should it be specified?
Also, I've noticed that the change-node in my version (node.js v18.14.2, node-red v3.0.2) doesn't have the memory/file option; was it eliminated, or do I have an old version, and where does the set go?
You have to use a persistent context store. Search for
Node red working with context
And checkout the link to the node red docs.
I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.
If you are putting a global into functionGlobalContext, you don't need a persistent store. Since the settings.js is already persistent. You put stuff in that area that is effectively a CONSTANT (unless you've defined a function of course).
I've watched some of the videos already; they're great. Watching videos on YouTube have become a bit more problematical with Greedy-Google cracking-down on Ad Blockers. Although I've found if you're not logged-in to an account your ok, or set you browser to delete session cookies, or use a non-chrome based browser like Opera. [The war between Ad-Blockers and Google starts; who will win?]
As was mentioned earlier, because you have not configured a persistent store.
If you had watched them all, or searched for the docs I suggested then you would have a better chance of answering the questions yourself. Let me do the search for you. https://nodered.org/docs/user-guide/context
If you want a global variable (rather than a constant) then use persistent context.
You should maybe try it. To be honest, I never have so I don't actually know the answer. My guess would be that it probably works but of course will be reset on restart. But I've never used it that way and always treat those as constants.
Good suggestion Julian; I actually have Brave on my cell; I try it on the PC's. Opera works well too and has a built-in VPN. It seems one of the simplest solutions is to just watch youtube videos without being signed-in to an account.
Julian, regarding the variable/constants in settings.js; I get the feeling that there isn't a lot of experience with using setting.js. The function I created in settings.js works quite well. I have a few ideas I want to try; I'll let you know as soon as I get back to it.
It has possibly not been as needed in more recent years with the expansion of other capabilities. But it was originally the one way to get reusable functions available to function nodes as well as the way to get external data into Node-RED easily. It has been there for a long time unchanged - I can't quite remember back the full 10 years now but I've a feeling it may have been there in the early release I first tried.