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

Edge function Error : ERR_MODULE_NOT_FOUND on an installed module #385

Open
Britnell opened this issue Feb 3, 2024 · 1 comment
Open

Comments

@Britnell
Copy link

Britnell commented Feb 3, 2024

Hey team,
I have an error I'm struggling to fix. I find similar MODULE_NOT_FOUNDS, but those seemed different.

  • I am deploying my astro site on vercel
  • Britnell/pushbullet
  • turso hosted sqlite db
  • building & running locally fine
  • e.g. homepage is fine
  • error happens on login api route , server crashes with :
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@libsql/client' imported from /var/task/.vercel/output/_functions/chunks/pages/app_m16mYN8C.mjs
    at new NodeError (node:internal/errors:405:5)
    at packageResolve (node:internal/modules/esm/resolve:965:9)
    at moduleResolve (node:internal/modules/esm/resolve:1022:20)
    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:876:12)
    at defaultResolve (node:internal/modules/esm/resolve:1242:79)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'

I am using libsql/client to connect to turso db
the endpoint is loading sql client :

import { createClient } from "@libsql/client/web";
export const turso = createClient({
  url: import.meta.env.TURSO_URL,
  authToken: import.meta.env.TURSO_TOKEN,
});

So it is failing to import an installed package. the build & install run fine, this works fine locally,
I was using pnpm, so tried out with npm i too, but still had the same issue.

I was using bcrypt package which had problems running on edge, which i replaced with bcryptjs
but libsql is a lightweight client suggested by turso, i feel like this should be able to work.
Do you have any other debugging tips I can try?

@Britnell
Copy link
Author

Britnell commented Feb 3, 2024

In fact i just deployed the same project to Netlify and it works fine, so this must be the astro/vercel adapter.
I don't know if you have access to my vercel deploy?

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

1 participant