Registry / devops / wait-for-pg

wait-for-pg

JSON →
library1.0.0jsnpmunverified

A CLI tool that waits for a PostgreSQL database to become available before proceeding. Version 1.0.0 uses meow for CLI, pg for PostgreSQL client, and esm for ES module support. It's a minimal wrapper around pg's connection logic, suitable for CI/CD scripts or Docker entrypoints. No active development since 2020, so consider alternatives like wait-on or pg_isready for newer Node versions.

npm install wait-for-pg
INSTALL
IMPORT
SIG · WAIT-FOR-PG
W
wait-for-pg
devopsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

waitForPG (CLI)
npx wait-for-pg
node -e 'require("wait-for-pg")'
wait-for-pg is primarily a CLI tool. It does not export any programmatic API. Use npx or global install.

Demonstrates global install and running the CLI with default or custom DATABASE_URL.

# Install globally npm install -g wait-for-pg # Use in script wait-for-pg # Or via npx without install npx wait-for-pg # Set environment variables or use defaults DATABASE_URL=postgres://user:pass@localhost:5432/mydb wait-for-pg
Debug
Known issues
gotchawait-for-pg is a CLI only; it does not export a programmatic API for use in Node.js code.
fix
Use child_process.execFile('npx', ['wait-for-pg']) or a library like wait-on for programmatic control.
affects: >=1.0.0
deprecatedThe package uses 'esm' which is deprecated in favor of native ESM in Node >=13.2.
fix
Consider using Node 20+ native ESM or replace with 'wait-on' or 'pg-connection-state'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'esm'
wait-for-pg requires esm but it may not be installed if not using global install.
fix
Install dependencies globally: npm install -g wait-for-pg or use npx wait-for-pg (npx automatically resolves dependencies).
wait-for-pg: command not found
wait-for-pg is not installed or not in PATH.
fix
Install globally: npm install -g wait-for-pg or use npx wait-for-pg.
Error: connect ECONNREFUSED 127.0.0.1:5432
PostgreSQL is not running or not accessible at the specified host/port.
fix
Ensure PostgreSQL is running and connection string (DATABASE_URL or defaults) is correct.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
meowrequiredCLI argument parsing
pgrequiredPostgreSQL client for connecting to database
esmrequiredEnables ES module syntax in Node < 13 by patching require
Agent activity
8 hits · last 30 days
node
8
Resources
wait-for-pg — npm install wait-for-pg · libregistry