In settings.js, functionGlobalContext I have
fs: require('fs')
and I am able to use it in a function node by:
const fs = context.global.fs;
then use fs.readdir
and it works fine. However when I run, from .node-red directory
npm list fs
npm list -g fs
they both come back empty. So I don't understand how it is working.
Maybe because fs is native module/part of node.js and so it isn’t installed like any of the external modules
Right - fs
is a core module and not managed by npm.
I can locate fs in /proc/sys/fs
in Raspbian
Yes, that probably explains it. I see I still have to require
it but not install it. Thanks.
That depends, it's not installed by default in all packages. I had to manually install it in a earlier version of Oracle Linux. I think it has been added now in the current version.
OK, so if I were using it in a created node should I put it in the node's package.json?
We are talking about the core fs module that has been a part of node.js since the very beginning.
Ah right, it may be that node.js wasn't installed either, because it wasn't a node-RED instance
This has nothing to do with /proc/sys/fs
OK, so in a created node I think I don't need to put it in package.json.
No all the core modules dont need to be put in the package json.
Great. Thanks all.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.