Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function runtime error: Cannot find module #11533

Closed
dglazkov opened this issue May 3, 2024 · 2 comments
Closed

Function runtime error: Cannot find module #11533

dglazkov opened this issue May 3, 2024 · 2 comments

Comments

@dglazkov
Copy link

dglazkov commented May 3, 2024

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.

kodiakhq bot pushed a commit to vercel/nft that referenced this issue May 10, 2024
`acorn-import-attributes` [did not support import assertions
before](#377 (comment)),
but now it does!

This is important because `acorn` is failing to parse `runner.js` in
[this issue](vercel/vercel#11533) due to an
import assertion.
kodiakhq bot pushed a commit that referenced this issue May 10, 2024
[@vercel/nft@0.27.0](https://github.com/vercel/nft/releases/tag/0.27.0) is necessary for parsing import assertions. Import assertions are causing [this issue](#11533).
@dglazkov
Copy link
Author

Can confirm it works with VERCEL_CLI_VERSION = vercel@34.2 set.

@onsclom
Copy link
Contributor

onsclom commented May 16, 2024

@dglazkov v34.2 just shipped as the default, so you can remove this env var now. Thanks for the great description and repro!

@onsclom onsclom closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants