(drizzle-kit) Unexpected character error

First time using drizzle, I have encountered Unexpected "�" error coming from drizzle.config.ts when running npx drizzle-kit generate (or any other drizzle-kit command). My drizzle.config.ts:
import "dotenv/config";
import { defineConfig } from "drizzle-kit";

export default defineConfig({
out: "./drizzle",
schema: "./db/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
import "dotenv/config";
import { defineConfig } from "drizzle-kit";

export default defineConfig({
out: "./drizzle",
schema: "./db/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
Here's the log of the error:
PS D:\SK-home-applainces> npx drizzle-kit generate
No config path provided, using default 'drizzle.config.ts'
Reading config file 'D:\SK-home-applainces\drizzle.config.ts'
Transform failed with 1 error:
D:\SK-home-applainces\drizzle.config.ts:1:0: ERROR: Unexpected "�"
PS D:\SK-home-applainces> npx drizzle-kit generate
No config path provided, using default 'drizzle.config.ts'
Reading config file 'D:\SK-home-applainces\drizzle.config.ts'
Transform failed with 1 error:
D:\SK-home-applainces\drizzle.config.ts:1:0: ERROR: Unexpected "�"
2 Replies
TOSL
TOSL5d ago
Must be some invisible character. Using VS code? What is the encoding of the file? Should be UTF-8. Delete the first line and retype it.
neon
neonOP5d ago
Ah, it was vscode indeed. Re-wrote the file in nvim and it works! Thanks.

Did you find this page helpful?