Skip to content

pnpm compatibility issue: @supabase/ssr module resolution fails in Next.js projects #139

@DavidCodec

Description

@DavidCodec

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

@supabase/ssr fails to resolve module imports when using pnpm as package manager, causing "Module not found: Can't resolve '@supabase/ssr'" error during Next.js compilation. The same project works perfectly with Bun package manager.

To Reproduce

  1. Followed the official Next.js + Supabase quickstart: https://supabase.com/docs/guides/getting-started/quickstarts/nextjs
  2. Used pnpm instead of npm for package management
  3. Implemented the exact code from the documentation for server client
  4. Run pnpm dev
  5. See compilation error

Exact code from documentation that fails:

// src/utils/supabase/server.ts
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'

export async function createClient() {
  const cookieStore = await cookies()

  return createServerClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
      cookies: {
        getAll() {
          return cookieStore.getAll()
        },
        setAll(cookiesToSet) {
          try {
            cookiesToSet.forEach(({ name, value, options }) =>
              cookieStore.set(name, value, options)
            )
          } catch {
            // The `setAll` method was called from a Server Component.
            // This can be ignored if you have middleware refreshing
            // user sessions.
          }
        },
      },
    }
  )
}

Expected behavior

The @supabase/ssr module should resolve correctly with pnpm, following the official documentation should work regardless of package manager.

Actual behavior

⨯ ./src/utils/supabase/server.ts:1:1
Module not found: Can't resolve '@supabase/ssr'
> 1 | import { createServerClient } from '@supabase/ssr'

System information

· OS: Windows
· Browser: Brave (server-side compilation error)
· Version of @supabase/ssr: latest 0.7.0
· Version of Node.js: 22.19.0
· Package manager: pnpm (fails) / Bun (works)

Additional context

· Documentation followed: Official Next.js quickstart guide
· Package manager comparison:
· ❌ Fails with pnpm (following docs exactly)
· ✅ Works with Bun (same code, same project)
· Next.js version: 16.0.1
· Error occurs during: Server-side compilation in Next.js dev server
· Impact: Cannot use official Supabase documentation with pnpm package manager

Workaround: Switching to Bun package manager temporarily resolves the issue, but this prevents teams standardized on pnpm from using Supabase with Next.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions