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

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

I’m using Functions and trying to use the @protobuf-ts/runtime npm module as a runtime dependency in my project. This runtime dependency works locally on my machine but when I deploy and then invoke my function I get greeted with Error: Cannot find module '@protobuf-ts/runtime', with the code MODULE_NOT_FOUND. I find this surprising as I installed this dependency the same way I installed another dependency, @aws-sdk/client-s3, which works as expected at runtime.
In an attempt to isolate the issue I have…
doctl serverless init --language ts test-do-project-0.nodejs:default to nodejs:18 in the project.ymlnpm install @protobuf-ts/runtime in the sample/hello function directory.@protobuf-ts/runtime and used it in the main function.When I deploy and invoke the function it errors with:
2023-05-02T21:57:49.277554254Z stdout: ReferenceError: exports is not defined in ES module scope
2023-05-02T21:57:49.277556929Z stdout: at file:///tmp/index.mjs:2:23
2023-05-02T21:57:49.277577833Z stdout: at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
I have tried fiddling with the tsconfig.json module settings to resolve the issue to no avail, only succeeding in matching my original error (Cannot find module '@protobuf-ts/runtime'). The function package.json does not include "type": "module".
If I instead npm install @aws-sdk/client-s3 and import and use it in hello.ts instead of @protobuf-ts/runtime, then everything works as expected. This makes me wonder if it is a problem specific to the @protobuf-ts/runtime npm module, but since it works locally on my machine, it must be something to do with how this dependency is handled in the DO Function Node runtime. Perhaps there is a difference in npm version?
I have read through both the Build Process and Functions Node.js JavaScript Runtime docs but can’t figure out what is going awry.
For reference and reproduction I have pushed the issue isolating Functions project to Github: https://github.com/willjvsmith/test-do-project-0
Thanks!
Rory McEwan
Anjanesh Lekshminarayanan
182d09356ab94d3893ddfaca4f0270
Prashant Kumbhat
kprichard
e452769e8f30404d81a3bc803143f4
robert
Eleanor
GamesmenJordan