Describe the bug
I'm creating a new project with
pnpm create bati --react --tailwindcss --trpc --hono --drizzle --cloudflare
after create the DB and check that everything works on run pnpm run dev
I'm trying to run pnpm run preview but fails with this and other errors.
> wrangler pages dev
⛅️ wrangler 3.69.1 (update available 3.70.0)
-------------------------------------------------------
✘ [ERROR] Could not resolve "fs"
../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/database.js:2:19:
2 │ const fs = require('fs');
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "path"
../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/database.js:3:21:
3 │ const path = require('path');
╵ ~~~~~~
To Reproduce
pnpm create bati --react --tailwindcss --trpc --hono --drizzle --cloudflare
pnpm drizzle:generate
pnpm drizzle:migrate
pnpm drizzle:seed
pnpm run preview
Additional context
I just try to follow the drizzle instruction, but I don't know how to make this works.
db.ts has this
import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";
import * as schema from "./schema";
const sqlite = new Database("sqlite.db");
export const db = drizzle(sqlite, { schema });
and export the db object, but in drizzle example, we have a request that has an env attribute that contains the DB.
Describe the bug I'm creating a new project with
pnpm create bati --react --tailwindcss --trpc --hono --drizzle --cloudflare
after create the DB and check that everything works on runpnpm run dev
I'm trying to runpnpm run preview
but fails with this and other errors.To Reproduce
Expected behavior preview should work out of the box. if D1 setup is required, the instructions should be part of the read me. https://orm.drizzle.team/docs/get-started-sqlite#cloudflare-d1
Additional context I just try to follow the drizzle instruction, but I don't know how to make this works. db.ts has this
and export the db object, but in drizzle example, we have a request that has an env attribute that contains the DB.
so I can not easly export that db object to be used in the rest of the app.