Function Compute connects to ApsaraBD for MongoDB service


#1

hello,

Are you familiar with Function Compute in Alibaba Clould? I am trying to get my function to connect to my ApsaraDB for MongoDB service. However when I invoke the function I have an error message “Cannot find ‘mongodb’”. Usually on my local machine it can be easily fixed by ‘npm i mongodb’ but how could I fix it on Function Compute?

Thanks and regards,
Neo


#2

Hi, Neo, here is the document about installing dependent libs on Function Compute. https://www.alibabacloud.com/help/doc-detail/58011.htm
I hope that helps.


#3

Hi @foolishneo,
You should be seeing /node_modules under your code repository.
mongodb is a custom module regarding Function Compute
if not, you can use npm install mongodb under your folder using fcli tool. If that is successfully installed you should see node_modules. This should fix the issue.
The whole process for this is explained here
https://www.alibabacloud.com/help/doc-detail/58011.htm#adding-modules

Let me know if that worked or you need any more help! :slight_smile: