redwert / pg-dump-restore

Utility that gives ability to call pg_dump and pg_restore from nodejs.
7 stars 8 forks source link

Error using pg-dump-restore: `ENOENT` for `pg_dump` command #14

Open gzsig opened 4 months ago

gzsig commented 4 months ago

I encountered an error when attempting to use the pg-dump-restore library to dump a PostgreSQL database. The process fails with an ENOENT error for the pg_dump command.

Error Message

{
  'full error :>> ': Error: Command failed with ENOENT: pg_dump --dbname=postgresql://postgres:sudo@localhost:5432/testeprod --format=custom --file=./dump.sql
  spawn pg_dump ENOENT
      at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
      at __node_internal_errnoException (node:internal/errors:623:12)
      at ChildProcess._handle.onexit (node:internal/child_process:283:19)
      at onErrorNT (node:internal/child_process:476:16)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawn pg_dump',
    path: 'pg_dump',
    spawnargs: [
      '--dbname=postgresql://postgres:sudo@localhost:5432/testeprod',
      '--format=custom',
      '--file=./dump.sql'
    ],
    originalMessage: 'spawn pg_dump ENOENT',
    shortMessage: 'Command failed with ENOENT: pg_dump --dbname=postgresql://postgres:sudo@localhost:5432/testeprod --format=custom --file=./dump.sql\n' +
      'spawn pg_dump ENOENT',
    command: 'pg_dump --dbname=postgresql://postgres:sudo@localhost:5432/testeprod --format=custom --file=./dump.sql',
    escapedCommand: 'pg_dump "--dbname=postgresql://postgres:sudo@localhost:5432/testeprod" "--format=custom" "--file=./dump.sql"',
    exitCode: undefined,
    signal: undefined,
    signalDescription: undefined,
    stdout: '',
    stderr: '',
    failed: true,
    timedOut: false,
    isCanceled: false,
    killed: false
  }
}
image

Steps to Reproduce

  1. Installed pg-dump-restore via yarn.
  2. Attempted to dump a PostgreSQL database using the provided syntax in the library documentation.
  3. The process failed with the error message above.
image

Expected Behavior

The library should successfully initiate a dump of the specified PostgreSQL database using pg_dump.

Actual Behavior

The command fails with an ENOENT error, indicating that pg_dump could not be found or executed.

Environment

RazaShehryar commented 2 months ago

You need to install libpq using brew. brew install libpq

After that, you will need to do this brew link --force libpq