ESM Support
As of v8.15.x node-postgres supporters the ECMAScript Module (ESM) format. This means you can use statements instead of or .
CommonJS modules are still supported. The ESM format is an opt-in feature and will not affect existing codebases that use CommonJS.
The docs have been changed to show ESM usage, but in a CommonJS context you can still use the same code, you just need to change the import format.
If you’re using CommonJS, you can use the following code to import the module:
ESM Usage
If you’re using ESM, you can use the following code to import the module:
Previously if you were using ESM you would have to use the following code: