P
Prisma2mo ago
eeplayrx

Failed to parse config file at "./prisma.config.ts"

Following the D1 guide here https://www.prisma.io/docs/guides/cloudflare-d1. When trying to migrate by running npx prisma migrate dev --name init, I get the error failing to parse the config file
3 Replies
Prisma AI Help
Prisma AI Help2mo ago
You chose to compile with the bot. One moment while I piece together your answer… If you're seeing "Failed to parse config file at './prisma.config.ts'" when running npx prisma migrate dev --name init while following the Cloudflare D1 guide, the most common causes are: 1. Syntax or Export Issues in prisma.config.ts
Ensure your prisma.config.ts is using a valid default export and matches the expected structure. For D1, it should look like this:
import path from 'node:path'
import type { PrismaConfig } from 'prisma'
import { PrismaD1 } from '@prisma/adapter-d1'
import 'dotenv/config'

export default {
earlyAccess: true,
schema: path.join('prisma', 'schema.prisma'),
migrate: {
async adapter(env) {
return new PrismaD1({
CLOUDFLARE_D1_TOKEN: env.CLOUDFLARE_D1_TOKEN,
CLOUDFLARE_ACCOUNT_ID: env.CLOUDFLARE_ACCOUNT_ID,
CLOUDFLARE_DATABASE_ID: env.CLOUDFLARE_DATABASE_ID,
})
},
},
} satisfies PrismaConfig

import path from 'node:path'
import type { PrismaConfig } from 'prisma'
import { PrismaD1 } from '@prisma/adapter-d1'
import 'dotenv/config'

export default {
earlyAccess: true,
schema: path.join('prisma', 'schema.prisma'),
migrate: {
async adapter(env) {
return new PrismaD1({
CLOUDFLARE_D1_TOKEN: env.CLOUDFLARE_D1_TOKEN,
CLOUDFLARE_ACCOUNT_ID: env.CLOUDFLARE_ACCOUNT_ID,
CLOUDFLARE_DATABASE_ID: env.CLOUDFLARE_DATABASE_ID,
})
},
},
} satisfies PrismaConfig

Make sure you are not using CommonJS (module.exports) and that your file is valid TypeScript/ESM syntax.
See example in the official guide. 2. Missing or Incorrect Environment Variables
The adapter function expects certain environment variables. Make sure your .env file contains:
CLOUDFLARE_D1_TOKEN=...
CLOUDFLARE_ACCOUNT_ID=...
CLOUDFLARE_DATABASE_ID=...

CLOUDFLARE_D1_TOKEN=...
CLOUDFLARE_ACCOUNT_ID=...
CLOUDFLARE_DATABASE_ID=...

and that you are loading them with import 'dotenv/config' at the top of your config file. 3. Prisma Version Compatibility
Ensure you are using Prisma ORM v6.11.0 or later, as earlier versions may not support the D1 adapter or the config file format as shown. 4. File Location and Path Resolution
The CLI resolves paths relative to the config file location. Make sure your prisma.config.ts is in the project root and your schema path is correct.
[See path resolution details](https://www.prisma.io/docs/orm/referenc e/prisma-config-reference#path-resolution). If you still encounter parsing errors, double-check for typos or misplaced commas/brackets in your config file. If the error persists, please provide the exact error message and your prisma.config.ts content for more targeted help. Reference: Cloudflare D1 migration guide 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurul2mo ago
Hey! Is this occuring on latest prisma version 6.13.0?
eeplayrx
eeplayrxOP2mo ago
Hello! These are the prisma versions installed
"@prisma/adapter-d1": "^6.13.0",
"@prisma/client": "^6.12.0",
"@prisma/extension-accelerate": "^2.0.2",

"prisma": "^6.12.0",
"@prisma/adapter-d1": "^6.13.0",
"@prisma/client": "^6.12.0",
"@prisma/extension-accelerate": "^2.0.2",

"prisma": "^6.12.0",
Hmm I've updated to 6.13.0 but still getting the same error
❯ grep 'prisma' package.json
"@auth/prisma-adapter": "^2.10.0",
"@prisma/adapter-d1": "^6.13.0",
"@prisma/client": "^6.13.0",
"@prisma/extension-accelerate": "^2.0.2",
"prisma": "^6.13.0",
❯ grep 'prisma' package.json
"@auth/prisma-adapter": "^2.10.0",
"@prisma/adapter-d1": "^6.13.0",
"@prisma/client": "^6.13.0",
"@prisma/extension-accelerate": "^2.0.2",
"prisma": "^6.13.0",
Copy of my prisma.config.ts
import path from 'node:path';
import type { PrismaConfig } from 'prisma';
import { PrismaD1 } from '@prisma/adapter-d1';

// import your .env file
import 'dotenv/config';

type Env = {
CLOUDFLARE_D1_TOKEN: string;
CLOUDFLARE_ACCOUNT_ID: string;
CLOUDFLARE_DATABASE_ID: string;
};

export default {
experimental: {
adapter: true,
},
schema: path.join('prisma', 'schema.prisma'),
migrate: {
async adapter(env) {
return new PrismaD1({
CLOUDFLARE_D1_TOKEN: env.CLOUDFLARE_D1_TOKEN,
CLOUDFLARE_ACCOUNT_ID: env.CLOUDFLARE_ACCOUNT_ID,
CLOUDFLARE_DATABASE_ID: env.CLOUDFLARE_DATABASE_ID,
});
},
},
} satisfies PrismaConfig<Env>;
import path from 'node:path';
import type { PrismaConfig } from 'prisma';
import { PrismaD1 } from '@prisma/adapter-d1';

// import your .env file
import 'dotenv/config';

type Env = {
CLOUDFLARE_D1_TOKEN: string;
CLOUDFLARE_ACCOUNT_ID: string;
CLOUDFLARE_DATABASE_ID: string;
};

export default {
experimental: {
adapter: true,
},
schema: path.join('prisma', 'schema.prisma'),
migrate: {
async adapter(env) {
return new PrismaD1({
CLOUDFLARE_D1_TOKEN: env.CLOUDFLARE_D1_TOKEN,
CLOUDFLARE_ACCOUNT_ID: env.CLOUDFLARE_ACCOUNT_ID,
CLOUDFLARE_DATABASE_ID: env.CLOUDFLARE_DATABASE_ID,
});
},
},
} satisfies PrismaConfig<Env>;
which should be the same as what's in the Prisma D1 doc

Did you find this page helpful?