Error generating schemas.
Why i cant generate the schemas?
Diogo@shadow-pc D:\....\link-shortener master npx @better-auth/cli generate
2025-02-27T01:31:33.675Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
at new PrismaClient (D:\Projetos\link-shortener\node_modules\.prisma\client\default.js:43:11)
at D:/Projetos/link-shortener/lib/auth.ts:5:16
at async Function.import (C:\Users\Diogo\AppData\Local\npm-cache\_npx\167ca1f116d365e6\node_modules\jiti\dist\jiti.cjs:1:199772)
at async resolveConfig (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:346:18)
at async loadConfig (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:146:23)
at async N (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:9:2140)
at async Command.Me (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:23:636)
Diogo@shadow-pc D:\....\link-shortener master npx @better-auth/cli generate
2025-02-27T01:31:33.675Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
at new PrismaClient (D:\Projetos\link-shortener\node_modules\.prisma\client\default.js:43:11)
at D:/Projetos/link-shortener/lib/auth.ts:5:16
at async Function.import (C:\Users\Diogo\AppData\Local\npm-cache\_npx\167ca1f116d365e6\node_modules\jiti\dist\jiti.cjs:1:199772)
at async resolveConfig (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:346:18)
at async loadConfig (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:146:23)
at async N (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:9:2140)
at async Command.Me (file:///C:/Users/Diogo/AppData/Local/npm-cache/_npx/167ca1f116d365e6/node_modules/@better-auth/cli/dist/index.mjs:23:636)
Diogo@shadow-pc D:\....\link-shortener master npx prisma generate
Environment variables loaded from .env
Error: Could not find Prisma Schema that is required for this command.
You can either provide it with `--schema` argument, set it as `prisma.schema` in your package.json or put it into the default location.
Checked following paths:
schema.prisma: file not found
prisma\schema.prisma: file not found
prisma\schema: directory not found
See also https://pris.ly/d/prisma-schema-location
Diogo@shadow-pc D:\....\link-shortener master npx prisma generate
Environment variables loaded from .env
Error: Could not find Prisma Schema that is required for this command.
You can either provide it with `--schema` argument, set it as `prisma.schema` in your package.json or put it into the default location.
Checked following paths:
schema.prisma: file not found
prisma\schema.prisma: file not found
prisma\schema: directory not found
See also https://pris.ly/d/prisma-schema-location
2 Replies
Here is my file structure:
(This is a fresh NextJS project where i made it until step 4 in https://www.better-auth.com/docs/installation#configure-database, including step 4)
.
├── app
│ ├── api
│ │ └── auth
│ │ └── [...all]
│ │ └── route.ts
│ ├── favicon.ico
│ ├── globals.css
│ ├── layout.tsx
│ └── page.tsx
├── components.json
├── eslint.config.mjs
├── lib
│ ├── auth-client.ts
│ ├── auth.ts
│ └── utils.ts
├── middleware.ts
├── next.config.ts
├── package-lock.json
├── package.json
├── postcss.config.mjs
├── public
│ ├── file.svg
│ ├── globe.svg
│ ├── next.svg
│ ├── vercel.svg
│ └── window.svg
├── tailwind.config.ts
└── tsconfig.json
.
├── app
│ ├── api
│ │ └── auth
│ │ └── [...all]
│ │ └── route.ts
│ ├── favicon.ico
│ ├── globals.css
│ ├── layout.tsx
│ └── page.tsx
├── components.json
├── eslint.config.mjs
├── lib
│ ├── auth-client.ts
│ ├── auth.ts
│ └── utils.ts
├── middleware.ts
├── next.config.ts
├── package-lock.json
├── package.json
├── postcss.config.mjs
├── public
│ ├── file.svg
│ ├── globe.svg
│ ├── next.svg
│ ├── vercel.svg
│ └── window.svg
├── tailwind.config.ts
└── tsconfig.json
Solution
create
prisma/schema.prisma
file