Drizzle foundations
Create the notes project
Set up a small TypeScript project with the current Drizzle 1.0 packages, Node SQLite, environment loading, and a repeatable command.
Let’s get a real database running first. We use the SQLite driver built into Node.js (node:sqlite), so there is nothing to install besides npm packages. You need Node.js 22.5 or newer for that module.
Install the packages
Create the project folder and install Drizzle. Drizzle 1.0 publishes its packages under the rc tag until the stable release, so the official getting-started page uses @rc:
mkdir drizzle-notes
cd drizzle-notes
npm init -y
npm i drizzle-orm@rc dotenv
npm i -D drizzle-kit@rc tsx typescript @types/node
Two packages do the work. drizzle-orm runs queries from your application. drizzle-kit is the command-line tool that compares schemas and writes migrations. Keep them on the same release line, or the migration tool may not understand the schema the ORM produces.
tsx runs TypeScript files directly. dotenv loads the .env file.
If Drizzle 1.0 is stable when you read this, the official page may have dropped @rc. Follow the current install command, not a tag copied from an old tutorial.
Point at a database file
Drizzle needs to know where the SQLite file lives. Put that in .env:
DB_FILE_NAME=notes.sqlite
The file does not exist yet. SQLite creates it the first time we open it.
Then create the folder for the database code:
mkdir -p src/db
What goes in Git and what doesn’t
Add notes.sqlite and .env to .gitignore. The database file is local state, and .env will hold real credentials once you move past SQLite.
We commit the schema and the migration files instead. Those describe how to rebuild the database from nothing, which is what another developer, or your deploy script, needs.
Check the versions you got
Before writing code, I like to know exactly what npm installed:
npm ls drizzle-orm drizzle-kit
You should see both packages on a 1.0.0-rc.x version, or on the same stable major. If one is on 0.x, the tag didn’t apply and the APIs in this course won’t match.
One more habit. Run npx tsc --init to get a tsconfig.json, then create src/index.ts with a deliberate type error, for example const port: number = 'three'. Run npx tsx src/index.ts. It works, because tsx strips types without checking them. Now run npx tsc --noEmit and see it fail. That’s the command that catches mistakes, so add it to your package.json scripts. Fix the line, and you have a project where types are checked and scripts run.
Lesson completed