Cannot find module

Cannot find module ‘got’
Require stack:

  • /var/task/node_modules/nayan-media-downloader/src/index.js
  • /var/task/routes/youtube.js
  • /var/task/index.js
    Did you forget to add it to “dependencies” in package.json?
    Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
    INIT_REPORT Init Duration: 1266.32 ms Phase: invoke Status: error Error Type: Runtime.ExitError

how to solve this, I am stuck reinstalling the node modules again and again. It runs fine locally but gives this error in vercel.

Hi @usmandevcraft. The error indicates that the got package is required but was not included as a dependency. Sometimes it helps to remove the lockfile and generate a new one.

It looks like nayan-media-downloader requires got as a subdependency for your project. It may be worth looking into that package and check how your project uses it.

I also noticed that the got package notes include this warning, which could be related somehow:

Warning: This package is native ESM and no longer provides a CommonJS export. If your project uses CommonJS, you will have to convert to ESM. Please don’t open issues for questions regarding CommonJS / ESM.

There are too many possible causes to be able to say for sure without more info. If you can share a minimal reproducible example, then someone here might be able to recognize what’s going wrong.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.