Create new file

I want to create a new file i using the fs function. I get the following error “ReferenceError: fs is not defined” . I tried that but error persists https://flows.nodered.org/flow/cdf160c36f082dc2a20cd1183ac6cd7d.

Have you followed the instructions in that example flow to add fs to functionGlobalContext in your settings file?

yes do i need to download fs via npm?

fs is a built-in node.js module, you don’t have to install anything else.

I see there is a typo in that example. It sets the fs property in functionGlobalContext, but then in the Function node it does: var fs = global.get('fs1') - note the fs1. That should match the property name set in functionGlobalContext

If you’ve copied that code without checking it, then you’ll have the same typo in your code.

1 Like

Thank you Nick for the constant support in the forums.