FG
💻 Software🗄️ Databases

[BUG]: `drizzle.config.ts` doesn't follow `tsconfig.json` for module path aliases (`@/app/lib/env`) but works for absolute paths (`./src/app/lib/env`)

Fresh5 days ago
Mar 14, 20260 views
Confidence Score75%
75%

Problem

What version of `drizzle-orm` are you using? ^0.28.6 What version of `drizzle-kit` are you using? ^0.19.13 Describe the Bug if i import using `'@/app/lib/env'`, it doesn't work but if i import using `'./src/app/lib/env'`, it works. for example, this works fine: drizzle.config.ts [code block] but the following throws an error `Error: Cannot find module '@/app/lib/env'`: drizzle.config.ts [code block] my `env` file looks like this: lib/env.ts [code block] Expected behavior this should work. drizzle.config.ts [code block] Environment & setup windows 10! my tsconfig looks like: tsconfig.json [code block]

Error Output

error `Error: Cannot find module '@/app/lib/env'`:

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix Module Path Alias Resolution in drizzle.config.ts

Medium Risk

The TypeScript module path aliases defined in tsconfig.json are not being recognized in drizzle.config.ts due to the way the module resolution is configured in the TypeScript compiler options. This can happen if the configuration is not properly set or if the environment running the code does not support the alias resolution.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update tsconfig.json

    Ensure that the 'baseUrl' and 'paths' properties are correctly set in your tsconfig.json to enable module path aliasing.

    json
    ```json
    {
      "compilerOptions": {
        "baseUrl": "./src",
        "paths": {
          "@/*": ["*"]
        }
      }
    }
    ```
  2. 2

    Check TypeScript Version Compatibility

    Ensure that your TypeScript version is compatible with the features used in your tsconfig.json. If necessary, update TypeScript to the latest version.

    bash
    ```bash
    npm install typescript@latest
    ```
  3. 3

    Verify Module Resolution in drizzle.config.ts

    Make sure that drizzle.config.ts is being executed in an environment that recognizes TypeScript path aliases. If you are using a build tool, ensure it is configured to use the TypeScript compiler options.

    typescript
    ```typescript
    import { config } from '@/app/lib/env';
    // Ensure this import works without errors
    ```
  4. 4

    Rebuild the Project

    After making changes to tsconfig.json and ensuring TypeScript is up to date, rebuild your project to apply the changes.

    bash
    ```bash
    npm run build
    ```
  5. 5

    Test the Import

    Run your application or the specific file that imports '@/app/lib/env' to confirm that the module resolution works as expected.

    bash
    ```bash
    npm start
    ```

Validation

Confirm that the import statement using '@/app/lib/env' works without throwing an error. You should see the application running without issues related to module resolution.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptdocsdrizzle/kitdocs/improvementspriority