I am using node-red 2.0.5. Node version is 14+
I am trying to import 'fs' library as I want to use readdirSync. I am following the steps mentioned in document - loading additional module
Please note, I am on windows 10. The node-red path is "\AppData\Roaming\npm\node_modules\node-red". I have updated the settings.js file -
functionGlobalContext: {
httpModule: require('http'),
querystring: require('querystring'),
os:require('os'),
fs:require('fs')
},
From my function node, when I access
global.get('fs').readdirSync(path)
I get the error -
[function:70da9a5b7abc738c] TypeError: Cannot read property 'readdirSync' of undefined.
When I console.log(global.get('fs')), it displays undefined. I have enabled exportGlobalContextKeys and printed the keys and it displayed empty list.
I have verified that node-red is being executed from "\AppData\Roaming\npm\node_modules\node-red"