Coming from a background in MVC frameworks, I absolutely love TypeORM. Being able to create type-safe models (entities) with an intuitive developer experience is fantastic. Not to mention they received new sponsorship, are lining up new maintainers, and seem to be making the most robust ORM out there.
Getting it setup with Nuxt, and strict type-checking though was a bit of a headache...
The Problem
TypeORM relies heavily on TypeScript decorators:
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id!: number
@Column()
email!: string
}
When you try to use this in a Nuxt project, you'll encounter two distinct types of errors:
Runtime errors - Nitro's esbuild compilation doesn't process decorators
Type-checking errors - vue-tsc complains about decorator signatures
These require separate fixes because they happen at different stages of the build process.
So what does this mean?
Well if you thought you could just update your nuxt apps server side to support decorators, and emit metadata then I've got bad news for you...
The tsconfigRaw option passes compiler settings directly to esbuild's TypeScript transform, enabling decorator support during the build.
Step 2: Configure the server
Nuxt 4 uses project references with multiple tsconfig files. The root tsconfig.json references generated configs in .nuxt/. For decorator type-checking to work, we need to create a server-specific tsconfig.
Yes, this duplicates the settings from server/tsconfig.json. Both are needed because nuxi typecheck runs vue-tsc in a way that doesn't pick up the server tsconfig overrides.
Step 5: Gitignore the Build Cache
The composite: true setting generates a build cache file in your server directory so we need to add it to the .gitignore
Copy
*.tsbuildinfo
That's it, now you can follow the rest of the TypeORM setup instructions.