Skip to content

The config file in .js format broke after the major update (node-pg-migrate 7 -> 8) #1504

Description

@datfcknadam

Describe the bug

There is a configuration file that is used during migrations

node-pg-migrate up -f "./config/config.js"

./config/config.js

module.exports = {
  host: process.env.POSTGRES_HOST,
  port: process.env.POSTGRES_PORT,
  database: process.env.POSTGRES_DB,
  user: process.env.POSTGRES_USER,
  password: process.env.POSTGRES_PASSWORD,
};

There were no problems with it in 7 major, but in 8 there is an error in the console.

Steps to reproduce

  1. Create a configuration file in js format (e.g., config.js)
  2. Install node-pg-migrate version 8
  3. Run node-pg-migrate up -f “config.js”

Logs

TypeError [ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE]: Module "file:///app/config/config.js" is not of type "json"
at handleInvalidType (node:internal/modules/esm/assert:109:9)
at validateAttributes (node:internal/modules/esm/assert:77:14)
at defaultLoad (node:internal/modules/esm/load:130:3)
at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:514:32)
at async ModuleJob._link (node:internal/modules/esm/module_job:115:19) {
code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE'
}

System Info

System:
    OS: Linux 6.8 Alpine Linux
    CPU: (4) x64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz
    Memory: 1.78 GB / 15.33 GB
    Container: Yes
    Shell: Unknown - /bin/sh
  Binaries:
    Node: 22.14.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/local/bin/npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions