Using 'fs' in the node function

#1

Hi everyone,

I just discover Node-red and I want to use the node "function" to manipulate files and folders with fs object.

I Uncomment this line in the settings.js

//var fs = require("fs");

and try to use

var fs = global.get('fs');

but the variable fs is set to undefined :worried:

Could You help me please, thank You

0 Likes

#2

Hi @lkaiser

this page of the docs explains how to add additional modules to the Function node - https://nodered.org/docs/writing-functions#loading-additional-modules

In short, you have to add them to the functionGlobalContext property in your settings file.

0 Likes

#3

Thank You very much knolleary !

it works very well.
I did not read correctly this section of the docs :roll_eyes:

0 Likes