How to include a require module in custom component
Hi,
I am trying to create a custom component for reading data from Azure Eventhubs. This requires the library require("@azure/event-processor-host") to be available in totaljs. Could you please let me know how can I add this library to totaljs so that my custom component gets installed successfully.
Thanks
In the component file add below line
exports.npm = ['@azure/event-processor-host'];
It will be installed automatically by Flow when the component is loaded. It might take some time to install so if you try to use it before that you may see an error in terminal. Just give it some more time.
Thank you. I will try this out.
If I would like to call back the npm function (e.g. var test = require('tape') from https://www.npmjs.com/package/tape) directly in Flow Function without creating a component (exports.npm = ['tape']). May I know if there is a way to set this config? Thank you!
Hi, if have access to command line on the machine running the Flow then just run npm install tape in the app directory. Then you can use it.
Yes, it is installed in the app/node_modules folder, but I couldn't call that function in Flow. When I used var test = require('tape'), it errors out that require is not a function. I also tried to set it as a global variable Tape : require('tape'), then using var tape = FLOW.variables.tape, but still not work
The componenet Function does not support require but Code should work