Hi,
I'm trying to import a third party library to my node-red project. I could manually set functionGlobalContext and it worked. functionGlobalContext: {os: require('os)}
and import it by const os = global.get('os')
But is it possible to do this programmatically? What I tried is that
const fs = require('fs');
// Path to settings file
const filePath = '/root/.node-red/settings.js';
// Read the settigns file using require
const config = require(filePath);
config.credentialSecret = "xx"
config.editorTheme.projects.enabled = true;
config.functionGlobalContext.os = "require('os')";
The problem with above code is that if I import it by global.get('os')
, it will give me a string of "require('os')".
The reason why I need to do this programmatically is that I have thousands of devices needs to be setup, it is impossible to manually set functionGlobalContext.
Any help would be appreciated.
Thank you!