Skip to content

Proper usage with #1525

@zeldigas

Description

@zeldigas

Context

I have a nestjs app written in typescript. By default nestjs does not use ESM or any custom module resolution and typescript transpiled code uses require(...)

node-pg-migrate works fine in "cli" mode, no issues.

I wanted to use in in "programmatic mode" for tests run (posgres in testcontainers + apply migrations with node-pg-migrate), but bumped in problem

Problem

Code in my test:

import { PostgreSqlContainer, StartedPostgreSqlContainer } from '@testcontainers/postgresql';
import { runner } from 'node-pg-migrate';

describe('DataLocationRepository', () => {
  let container: StartedPostgreSqlContainer;

  beforeAll(async () => {
    container = await new PostgreSqlContainer('library/postgres:17.6').start();
    await runner({
      databaseUrl: container.getConnectionUri(),
      dir: './src/db/migrations',
      direction: 'up',
      migrationsTable: 'pgmigrations',
      count: Infinity,
    });
  }, 60_000);

  afterAll(async () => {
    await container.stop();
  });
  // here the plan was to writ tests
});

I got complier error when trying to import runner in my ide (IntelliJ):

TS2307: Cannot find module node-pg-migrate or its corresponding type declarations.
There are types at
<repo-root>/node_modules/node-pg-migrate/dist/bundle/index.d.ts
, but this result could not be resolved under your current moduleResolution setting. Consider updating to node16, nodenext, or bundler

node-pg-migrate is the only package that produces such error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions