Report this

What is the reason for this report?

Does a DO function do npm install, or I need to manually upload the node_modules folder?

Posted on June 4, 2025

I have some issues deploying a serverless function. First, I use two big packages like google document-ai and aws-rekognition. When I try to deploy using these two, it fails since the .zip becomes too big. If I exclude the node_modules from the deployment, when I test the function it says it does not work. Now, I moved my two packages to use REST API calls, but I still have ‘sharp’ library for image processing, and unfortunately I cannot deploy the node_modules for it, since it’s not compatible from my OSX to Linux. So my question is, do DO functions do npm install, or I always have to sumit the node_modules folder?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey!

You don’t need to upload your node_modules folder manually when deploying to DigitalOcean Functions. As long as you include a valid package.json, DigitalOcean will run npm install --production during deployment for you.

If you’re using native modules like sharp, I think that it’s best to deploy with the --remote-build flag:

doctl serverless deploy . --remote-build

This ensures the Functions service performs a remote build, which usually avoids compatibility issues that can come up when developing on macOS:

https://docs.digitalocean.com/products/functions/reference/build-process/#local-and-remote-builds

That said, sharp and other native modules can still be tricky depending on how they’re bundled. If you continue hitting issues, I’d recommend reaching out to the DigitalOcean support team to dig deeper:

https://do.co/support

Hope this helps! Let us know how it goes!

- Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.