{"id":43451,"library":"node-postgres","title":"node-postgres","description":"node-postgres is a pure JavaScript PostgreSQL client for Node.js. Current version 0.6.2 is an early release with basic client, pool, SSL, and transaction support. It is unopinionated and low-level, requiring manual BEGIN/COMMIT/ROLLBACK for transactions. Unlike `pg` (the popular PostgreSQL client), this package has few features and is likely experimental or a simple wrapper.","status":"active","version":"0.6.2","language":"javascript","source_language":"en","source_url":"https://github.com/fuxingZhang/postgres","tags":["javascript","database","pg","libpg","postgre","postgres","postgresql"],"install":[{"cmd":"npm install node-postgres","lang":"bash","label":"npm"},{"cmd":"yarn add node-postgres","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-postgres","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS only: package does not support ESM or TypeScript.","wrong":"const Client = require('node-postgres').Client;","symbol":"Client","correct":"const { Client } = require('node-postgres');"},{"note":"Pool is exported directly from 'node-postgres', not a separate package.","wrong":"const { Pool } = require('pg-pool');","symbol":"Pool","correct":"const { Pool } = require('node-postgres');"},{"note":"Standard destructured import for both classes.","wrong":"const client = require('node-postgres').Client;","symbol":"Client and Pool","correct":"const { Client, Pool } = require('node-postgres');"}],"quickstart":{"code":"const { Client } = require('node-postgres');\n\n(async () => {\n  const client = new Client({\n    user: 'postgres',\n    host: '127.0.0.1',\n    database: 'test',\n    password: process.env.DB_PASSWORD ?? 'password',\n    port: 5432\n  });\n  \n  await client.connect();\n  const res = await client.query('SELECT NOW()');\n  console.log(res.rows[0]);\n  await client.end();\n})().catch(console.error);","lang":"javascript","description":"Connect to PostgreSQL, run a query, and close the connection using Client."},"warnings":[{"fix":"Use try/finally: const client = await pool.connect(); try { /* queries */ } finally { client.release(); }","message":"Always release client back to pool after checkout to avoid leaks.","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Checkout a client from pool, execute BEGIN/COMMIT/ROLLBACK manually, then release.","message":"Transactions must use the same client; do not use pool.query for transactions.","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Pass ssl: { key: fs.readFileSync('path').toString(), cert: fs.readFileSync('path').toString() }.","message":"SSL configuration requires key and cert as strings (read from files via fs.readFileSync).","severity":"gotcha","affected_versions":">=0.6.0"}],"env_vars":null,"search_vec":"'0.6.2':17 'basic':23 'begin/commit/rollback':39 'client':12,24,47 'current':15 'databas':62 'earli':20 'experiment':56 'featur':52 'javascript':10,61 'level':36 'libpg':64 'like':55 'low':35 'low-level':34 'manual':38 'node':2,5 'node-postgr':1,4 'node.js':14 'packag':49 'pg':43,63 'pool':25 'popular':45 'postgr':3,6,65,66 'postgresql':11,46,67 'pure':9 'releas':21 'requir':37 'simpl':59 'ssl':26 'support':29 'transact':28,41 'unlik':42 'unopinion':32 'version':16 'wrapper':60","created_at":"2026-06-05T16:59:51.736807+00:00","updated_at":"2026-06-05T16:59:51.736807+00:00","problems":[{"fix":"Set host: '127.0.0.1' and port: 5432 explicitly in Client/Pool config.","cause":"Default connection tries Unix socket; host/port not specified correctly.","error":"Error: connect ENOENT /tmp/.s.PGSQL.5432"},{"fix":"Ensure queries are made before calling end(). Use a single client per transaction.","cause":"Trying to run query on a client after client.end() or pool.end() has been called.","error":"Error: Client was closed and is not queryable"},{"fix":"Use const { Pool } = require('node-postgres');","cause":"Importing Pool incorrectly: using require('pg-pool') vs 'node-postgres'.","error":"Error: Pool is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/fuxingZhang/postgres","github":"https://github.com/fuxingZhang/postgres","docs":null,"changelog":null,"pypi":null,"npm":"node-postgres","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}