Import problem with drizzle-kit generate

I'm migrating from TypeORM to Drizzle in my Node.js project to manage player data, but I'm facing an issue. I have created schemas in a folder to manage all of them, for example, core/schemas/*.schema.ts.

Some schemas need to use interfaces or types from my project or platform node modules. For example, I created a custom type for Vector3 from alt-server as follows:
Custom type code:
import { Vector3 } from 'alt-server';
import { customType } from 'drizzle-orm/mysql-core';

export const vector3 = (name: string) =>
    customType<{ data: Vector3; driverData: string; notNull: true; default: false }>({
        ...not nitro limit
        fromDriver(value: string): Vector3 {
            const { x, y, z } = JSON.parse(value);
            return new Vector3(x, y, z);
        },
    })(name);
Schema code:
import { vector3 } from '../custom-types';

export const atmsTable = mysqlTable(
    'atms',
    {
        id: serial().notNull(),
        pos: vector3('pos'),
        rot: vector3('rot'),
    }...not nitro limit
);
When I run drizzle-kit generate to generate SQL files for all the schemas, I get the following error:
Error: Cannot find module 'alt-server'
Require stack:
- src\server\core\custom-types.ts
- src\server\core\schemas\accounts.schema.ts
- node_modules\drizzle-kit\bin.cjs
Even if I use declare module or define the Vector3 class directly in the schema, I still encounter this issue when importing custom interfaces from other places. In short, I am unable to import external code.
Was this page helpful?