Skip to content

Function runtime error: Cannot find module #11533

@dglazkov

Description

@dglazkov

Here's the minimal repro: https://github.com/dglazkov/vercel-test

  1. Create a Vercel project
  2. Deploy the github project above in it
  3. Go to <deployment url>/api/hello.

It gets a consistent "This Serverless Function has crashed." error. When I look into the runtime logs, I see that the the problem is described as follows:

Error: Cannot find module '/var/task/node_modules/@google-labs/breadboard/dist/src/remote.js' imported from /var/task/node_modules/@google-labs/breadboard/dist/src/runner.js
at finalizeResolution (node:internal/modules/esm/resolve:269:11)
at moduleResolve (node:internal/modules/esm/resolve:937:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1161:14)
at defaultResolve (node:internal/modules/esm/resolve:1204:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
at link (node:internal/modules/esm/module_job:86:36) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///var/task/node_modules/@google-labs/breadboard/dist/src/remote.js'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
INIT_REPORT Init Duration: 241.97 ms	Phase: invoke	Status: error	Error Type: Runtime.ExitError
Unknown application error occurred

When I look at the node_modules in the project, the remote.js file is present:

$ find node_modules | grep remote.js    
node_modules/@google-labs/breadboard/dist/src/remote.js
node_modules/@google-labs/breadboard/dist/src/remote.js.map
$

However, when I do a local vercel build, I can see that this file is not present in the node_modules of the function:

$ find .vercel/output/functions/api/hello.func/node_modules | grep "remote.js" 
$

It looks like it's getting dropped somehow? Not sure where. I gave the @vercel/node a quick spelunk and couldn't find anything that jumped out at me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions