How to use Node Modules in Cloud Functions

Hi All,

Iā€™m trying to work with ā€œfilesā€ in cloud-functions. Basically following this:
https://docs.moralis.io/files#server-side

Iā€™m creating the cloud function in the portal using the web IDE.

When I try and invoke the cloud function Iā€™m getting the error:
ā€œError: Cannot find module ā€˜request-promiseā€™ā€

Basically it seems to have an issue with the following line in the demo code.:
const request = require(ā€˜request-promiseā€™);

How do you install node modules in cloud functions?

Thanks,

Hi itheum,

Thanks for reporting this issue! You can use Files in Clode Code in the same was as in the Browser. The docs here were incorrect and have been updated. The ā€œserver sideā€ in this context is NodeJs, not Cloud Code.

1 Like

How do I use Files here? do I upload all the required node modules?

for now it works if you upload in same cloud code also the code from the module, it doesnā€™t work with any module this way