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

Fix module resolution errors for @v1 packages in Vercel deployment #60

Open
while-basic opened this issue Jan 17, 2025 · 0 comments
Open

Comments

@while-basic
Copy link

Fix module resolution errors for @v1 packages in Vercel deployment

Issue Description

Build is failing during Vercel deployment for the backend application (/apps/app). The frontend (/apps/web) deploys successfully.

Project Structure

  • Single git repository with two deployment destinations:
    • /apps/web - Frontend (port 3001)
    • /apps/app - Backend (port 3000)
  • Using default build and development settings on Vercel
  • No active configuration overrides

Deployment Configuration

Backend (/apps/app) vercel.json:

?

Critical Information

  1. Build Process:

    • Uses pnpm for package management
    • Requires navigation to root directory for installation
    • Returns to app directory for build
    • Uses Next.js framework settings
    • Outputs to .next directory
  2. Package Resolution:

    • Monorepo structure with shared packages in /packages
    • Workspace dependencies managed by pnpm
    • Module imports using @v1 namespace
  3. Error Details
    Backend build fails with multiple module resolution errors:

  4. In ./src/app/[locale]/layout.tsx:

    • Cannot resolve @v1/ui/globals.css
    • Cannot resolve @v1/ui/cn
  5. In ./src/components/google-signin.tsx:

    • Cannot resolve @v1/supabase/client

Root Cause

The @v1 packages are not properly configured in the monorepo setup for Vercel deployment. While these packages work in local development, they fail during Vercel's build process.

Environment Details

  • Deployment Platform: Vercel
  • Package Manager: pnpm
  • Framework: Next.js
  • Development Ports:
    • Frontend: 3001
    • Backend: 3000

Steps to Reproduce

  1. Push changes to repository
  2. Vercel automatically triggers deployment
  3. Frontend (/apps/web) builds successfully
  4. Backend (/apps/app) build fails with module resolution errors

Proposed Solution

  1. Verify package.json configurations:
    • Check workspace dependencies
    • Ensure proper package exports
    • Verify Vercel's monorepo support settings
  2. Update tsconfig paths:
    • Add proper path aliases for @v1 packages
  3. Verify build configuration:
    • Check webpack/next.js module resolution settings
    • Ensure Vercel is properly configured for monorepo builds
  4. Consider Vercel-specific adjustments:
    • Verify monorepo project settings in Vercel dashboard
    • Check if root directory setting needs adjustment
    • Validate build command traversal

Impact

  • Blocking backend deployment
  • Frontend remains operational
  • Affecting core functionality (auth, styling)

Priority

High - blocking backend deployment pipeline

Additional Notes

  • The build command includes directory traversal (cd ../..) which might affect module resolution
  • The frontend deployment succeeds without a specific vercel.json, using default settings
  • Package resolution might be affected by the build command's directory changes

Labels

  • bug
  • build
  • vercel
  • monorepo
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