This example flow uses the native Node.JS fs and path modules to read a list of file names having a specified file extension from a given folder.
You can pass the folder and extension strings in via the msg.payload. Output is a single message for each file found. The payload will be the full file path. Everything other than the payload will be passed through to each output msg.
You would actually probably be better off using a 3rd party module as indicated in the main code but this may be a useful example of using modules in a Node-Red function node.
Note that function nodes run in a "sandbox" and have restricted syntax. As such, you cannot do:
var fs = require('fs');