I’m trying to start using the https://www.npmjs.com/package/carbone document generator.
Installed using “npm install -g carbone” command.
The example code for the test uses the following variable ( const fs = require(‘fs’) ), which, as far as I understand, should refer to the “fs” dependency built into NodeJs.
It gives me an error (see screenshot).
I understand that there is nothing in this “fs” path, but what should be the correct path in this case?
Or is the problem something else?
Hi @Roket, you’d need to specifically allow the use of modules in n8n. You can allow a built-in module using the NODE_FUNCTION_ALLOW_BUILTINenvironment variable and external modules using NODE_FUNCTION_ALLOW_EXTERNAL.
So once you set NODE_FUNCTION_ALLOW_BUILTIN=fs, you should be able to require fs in your Function code.
When I try to run the same code as in your screenshot (the carbone example code), the function node runs without complaints, but there is no file created. I must be missing something.
I have tried to save a file with fs.writeFileSync, and it can create a file on disk.
I have also tried to put the carbone code in a index.js file and run with “node index.js” inside the n8n container. That works as expected and the result.odt gets created on disk.