#Error Convex Auth

4 messages · Page 1 of 1 (latest)

hybrid pelican
#

I'm getting this error right after setting up convex auth with npx @convex-dev/auth (I meant to use bun but I think thats fine) when I bunx convex dev.

❯ bunx convex dev
⠸ Bundling component schemas and implementations...
✘ [ERROR] Could not resolve "@convex-dev/auth/server"

    convex/auth.ts:1:27:
      1 │ import { convexAuth } from "@convex-dev/auth/server";
        ╵                            ~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@convex-dev/auth/server" as external to exclude it from the bundle, which
  will remove this error and leave the unresolved path in the bundle.
feral ferryBOT
#

Hi @hybrid pelican. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The error you're seeing:

✘ [ERROR] Could not resolve "@convex-dev/auth/server"

typically means that the Convex bundler cannot find the @convex-dev/auth/server package. This issue is commonly encountered in monorepo setups or when using certain package managers like Bun or pnpm, which can sometimes cause dependency resolution issues.

Key things to check and try:

  1. Ensure the package is installed in the correct location.
    Make sure that @convex-dev/auth is installed in the same workspace/package where your Convex backend code (e.g., convex/auth.ts) lives. In monorepos, avoid installing it only at the root if your backend is in a subpackage—install it in the backend package as well if needed.

  2. Check your package manager.
    There are known issues with Bun and pnpm in monorepo setups where dependencies may not be resolved as expected. If you're using Bun, consider switching to npm or pnpm for your Convex backend, as Bun has been reported to cause esoteric issues with dependency resolution in Convex projects. See related discussions:
    Tanstack + Convex monorepo issues
    Expo/monorepo issues

  3. Reinstall dependencies.
    Delete your node_modules and lockfile (bun.lockb, pnpm-lock.yaml, or package-lock.json), then reinstall dependencies. This can resolve issues where multiple versions or missing packages are causing conflicts.

#
  1. Check import paths.
    Make sure you are not importing server-side code (like @convex-dev/auth/server) in files that are used by your frontend or mobile app. Only your backend should import from @convex-dev/auth/server—importing it elsewhere can cause bundling errors, especially in Expo or React Native projects.

  2. If using Bun, try npm or pnpm.
    Several users have reported that switching from Bun to npm or pnpm resolved similar issues. Bun's module resolution can behave differently and may not always work with all packages out of the box.

  3. If you are in a monorepo, avoid cross-importing backend code in frontend packages.
    For example, don't import backend helpers or schema files into your frontend, as this can cause the frontend to try to resolve backend-only dependencies like @convex-dev/auth/server and fail.

Summary:
This is almost always a dependency resolution issue. Double-check where your dependencies are installed, consider switching package managers if you're using Bun, and ensure your import paths are correct for your project structure. If you continue to have issues, try a clean install with npm or pnpm and ensure your backend and frontend dependencies are separated as needed.

References:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: