Skip to content

fix: prisma client not found error - #22

Open
mudiageo wants to merge 4 commits into
mainfrom
fix-prisma-client-not-found
Open

fix: prisma client not found error#22
mudiageo wants to merge 4 commits into
mainfrom
fix-prisma-client-not-found

Conversation

@mudiageo

@mudiageo mudiageo commented Sep 7, 2025

Copy link
Copy Markdown
Owner

User description

Projects not using prisma are getting prisma client not found error. We're using prisma internally to get types for PrismaClient. This PR moves the types from the src/lib/database.js to the src/lib/types directory


PR Type

Bug fix


Description

  • Move database types to separate types directory

  • Fix Prisma client import error for non-Prisma projects

  • Isolate Prisma dependency from main database module


Diagram Walkthrough

flowchart LR
  A["src/lib/database.ts"] -- "move types" --> B["src/lib/types/database.ts"]
  C["src/lib/types/config.ts"] -- "update import" --> B
Loading

File Walkthrough

Relevant files
Bug fix
database.ts
Remove database types and Prisma import                                   

src/lib/database.ts

  • Remove database type definitions and Prisma import
  • Import DatabaseConfig from types directory
  • Keep only adapter creation utility function
+1/-42   
config.ts
Update DatabaseConfig import path                                               

src/lib/types/config.ts

  • Update import path for DatabaseConfig type
  • Change from relative import to types directory
+1/-1     
database.ts
Add database types with Prisma import                                       

src/lib/types/database.ts

  • Create new file with database type definitions
  • Include Prisma client import and all database interfaces
  • Define comprehensive database provider types
+41/-0   

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel

vercel Bot commented Sep 7, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
svelte-guardian Ready Ready Preview Comment Sep 8, 2025 0:56am

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @mudiageo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a specific issue where projects not configured to use Prisma were failing due to an unexpected dependency on Prisma types. The core change involves refactoring the location of database-related type definitions, including those for Prisma, into a dedicated types file. This ensures that the type system correctly handles dependencies, preventing errors in environments where Prisma is not present and improving the overall modularity of the codebase.

Highlights

  • Fix Prisma Client Not Found Error: Projects not utilizing Prisma were encountering a 'Prisma client not found' error due to internal type imports. This PR resolves the issue by isolating Prisma-related type definitions.
  • Type Definition Refactoring: The PrismaClient types and other database configuration types have been relocated from src/lib/database.ts to a new dedicated type file at src/lib/types/database.ts.
  • Improved Module Separation: This change enhances module separation by ensuring that projects not dependent on Prisma do not inadvertently pull in Prisma-related dependencies through type imports, preventing runtime errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Import

The new types file references the Adapter type in CustomAdapterConfig but does not import it. This will cause a type error and should import Adapter from '@auth/core/adapters'.

// Specific database provider configurations
export interface CustomAdapterConfig extends BaseDatabaseConfig {
	type: 'custom';
	adapter: Adapter;
}
Optional Dependency Leak

Importing PrismaClient type from '@prisma/client' at the top-level can still trigger type resolution errors in projects without Prisma. Consider using an ambient type, interface, or a local declaration to avoid requiring the package, or wrap behind a type-only import with module augmentation guidance.

import type { PrismaClient } from '@prisma/client'

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly moves database-related types to a separate file to resolve an issue with the Prisma client. However, this refactoring has introduced a couple of issues. A type dependency (Adapter) was not moved along with the code that uses it, which will cause a build failure. Additionally, other types used for casting in database.ts are now out of scope and need to be imported. I've also pointed out that some database configuration types (MongoDBConfig, SupabaseConfig) were missing altogether and this is a good opportunity to add them for completeness and to fix related type errors.

Comment thread src/lib/database.ts Outdated
| DrizzleConfig
| CustomAdapterConfig;

import type { DatabaseConfig } from './types/database'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The types DrizzleConfig, MongoDBConfig, and SupabaseConfig are used for type casting within createDatabaseAdapter but are no longer defined or imported in this file. They need to be imported from ./types/database to prevent build errors. Note that this is also dependent on MongoDBConfig and SupabaseConfig being defined in that file, which I've commented on separately.

Suggested change
import type { DatabaseConfig } from './types/database'
import type { DatabaseConfig, DrizzleConfig, MongoDBConfig, SupabaseConfig } from './types/database'

Comment thread src/lib/types/database.ts
Comment thread src/lib/types/database.ts
Comment on lines +35 to +41
}

// Union type for all database configurations
export type DatabaseConfig =
| PrismaConfig
| DrizzleConfig
| CustomAdapterConfig; No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The types MongoDBConfig and SupabaseConfig are used in src/lib/database.ts but are not defined. They should be defined here and included in the DatabaseConfig union type. This will fix type errors in database.ts.

}

export interface MongoDBConfig extends BaseDatabaseConfig {
	type: 'mongodb';
	client: any;
	database: string;
}

export interface SupabaseConfig extends BaseDatabaseConfig {
	type: 'supabase';
	client: any;
	serviceRole?: any;
}

// Union type for all database configurations
export type DatabaseConfig =
	| PrismaConfig
	| DrizzleConfig
	| CustomAdapterConfig
	| MongoDBConfig
	| SupabaseConfig;

@qodo-code-review

qodo-code-review Bot commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Remove direct Prisma type import

Moving the Prisma import into a types file still forces TypeScript to resolve
'@prisma/client', so non‑Prisma consumers will continue to see "module not
found" during type-checking. Avoid importing Prisma in public types; instead
model the Prisma client as unknown/any or a minimal structural interface, or
gate it behind an optional peer dependency with separate .d.ts that only applies
when Prisma is installed. This fully decouples the package from Prisma and
actually resolves the error for non‑Prisma projects.

Examples:

src/lib/types/database.ts [1-29]
import type { PrismaClient } from '@prisma/client'

// Comprehensive database provider types
export type DatabaseProviderType =
	| 'prisma'
	| 'drizzle'
	| 'mongodb'
	| 'postgres'
	| 'mysql'
	| 'sqlite'

 ... (clipped 19 lines)

Solution Walkthrough:

Before:

// src/lib/types/database.ts
import type { PrismaClient } from '@prisma/client'

export interface PrismaConfig extends BaseDatabaseConfig {
	type: 'prisma';
	client: PrismaClient;
}

export type DatabaseConfig =
	| PrismaConfig
	| DrizzleConfig
	| CustomAdapterConfig;

After:

// src/lib/types/database.ts
// No direct import from '@prisma/client'

export interface PrismaConfig extends BaseDatabaseConfig {
	type: 'prisma';
	// Use 'any' to avoid a hard dependency on '@prisma/client'
	client: any;
}

export type DatabaseConfig =
	| PrismaConfig
	| DrizzleConfig
	| CustomAdapterConfig;
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that the PR's approach does not solve the core problem, as non-Prisma users will still encounter type resolution errors, thus defeating the PR's primary goal.

High
Possible issue
Remove undefined external type

The Adapter type is not defined in this file and will cause a compile error.
Loosen the type to avoid a missing-type failure while keeping the file
self-contained.

src/lib/types/database.ts [22-25]

 export interface CustomAdapterConfig extends BaseDatabaseConfig {
 	type: 'custom';
-	adapter: Adapter;
+	// Avoid hard-typing to external Adapter to prevent missing type errors
+	adapter: unknown;
 }
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: This suggestion correctly identifies that the Adapter type is used without being imported in the new file, which would cause a compilation error, thus fixing a bug introduced in the PR.

High
Avoid hard Prisma dependency

Avoid a hard compile-time dependency on Prisma. Remove the Prisma type import
and widen the client type to avoid "Cannot find module '@prisma/client'" in
environments without Prisma installed.

src/lib/types/database.ts [26-29]

-import type { PrismaClient } from '@prisma/client'
-
-...
 export interface PrismaConfig extends BaseDatabaseConfig {
 	type: 'prisma';
-	client: PrismaClient;
+	// Use a broad type to avoid requiring @prisma/client at compile time
+	client: unknown;
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 7

__

Why: This is a good suggestion that improves dependency management by removing the hard compile-time dependency on @prisma/client, which would cause issues for users not using Prisma.

Medium
  • Update

@mudiageo
mudiageo requested a review from Copilot September 7, 2025 20:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a Prisma client import error that was affecting projects not using Prisma by isolating Prisma-related type dependencies from the main database module.

  • Moved all database type definitions from src/lib/database.ts to a dedicated types file
  • Replaced direct Prisma import with type-only import in the types directory
  • Updated import paths to reference the new types location

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/lib/types/database.ts New file containing all database type definitions with isolated Prisma type import
src/lib/types/config.ts Updated DatabaseConfig import path to reference the new types directory
src/lib/database.ts Removed type definitions and Prisma import, keeping only the adapter utility function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/lib/types/database.ts
@@ -0,0 +1,41 @@
import type { PrismaClient } from '@prisma/client'

Copilot AI Sep 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type-only import from '@prisma/client' will still cause a runtime error if the package is not installed. Consider using a conditional type import or making this dependency optional to truly isolate Prisma from non-Prisma projects.

Copilot uses AI. Check for mistakes.
Comment thread src/lib/types/database.ts
// Specific database provider configurations
export interface CustomAdapterConfig extends BaseDatabaseConfig {
type: 'custom';
adapter: Adapter;

Copilot AI Sep 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Adapter type is not imported in this file. This will cause a TypeScript error since Adapter is used but not defined or imported.

Copilot uses AI. Check for mistakes.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 8, 2025

Copy link
Copy Markdown

Deploying svelte-guardian with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6c6b6ba
Status:🚫  Build failed.

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants