node-pg-migrate: `pg@8.15.1` breaks node-pg-migrate: cannot access './lib/connection-parameters.js' due to package exports

Describe the bug

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./lib/connection-parameters.js’ is not defined by “exports” in [path-to-repo]\node_modules\pg\package.json

Steps to reproduce

No response

Logs

No response

System Info

window & linux

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
    Memory: 13.70 GB / 31.83 GB
  Binaries:
    Node: 23.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Just a heads-up: I’ve submitted a PR to the pg repo to fix the issue we encountered. The problem was due to pg@8.15.1 restricting access to internal modules like lib/connection-parameters.js, which node-pg-migrate relies on.

The PR is here: https://github.com/brianc/node-postgres/pull/3428. Once it’s merged and a new pg version is released, updating should resolve the issue.

In the meantime, downgrading to pg@8.14.1 is a viable workaround.

Thanks for your patience!

Hey sorry about that. PR merged (thank you @brenoepics for the fix while I was sleeping!) and a new patch version of pg related modules released now. pg@8.15.2 should work. Please feel free to report any other issues you find!

Is there something I should do from my side? e.g. Is there a migration path to something I should do, to e.g. not import it from such a nesting package path? The way right now felt already like a hacky way and not official supported but just accessing something not meant to be exported publicly officially.

its okay to import deeply if you need to, though it wouldn’t hurt to LMK what you need exported more “officially” and I can do that - that makes it more a part of the public API. I’ve learned through this incident though anything you put on npm can be considered the public API if its importable and your lib is installed enough. 😄

I have fixed this on my side so you should be good if you just update to the most recent version of pg - if you run into any other issues please don’t hesitate to let me know, and thanks for this package!

workaround does not apply to npx run, right?

Likely possible with something like npx --package node-pg-migrate --package pg@8.14.1 node-pg-migrate --version By default, npx installs the latest versions of dependencies, so without pinning pg, it pulls 8.15.1, which breaks internal imports. Image

Weird that even with that I couldn’t make it work (maybe because I 'm using 8). Had to add a package.json and pin it there instead. Hope your PR gets merged soon, thanks 💯

workaround does not apply to npx run, right?

Likely possible with something like npx --package node-pg-migrate --package pg@8.14.1 node-pg-migrate --version By default, npx installs the latest versions of dependencies, so without pinning pg, it pulls 8.15.1, which breaks internal imports. Image

I’m investigating the problem and have already managed to reproduce it. Apparently, it’s the latest minor version of pg (8.15.1) that no longer exports this—possibly related to https://github.com/brianc/node-postgres/pull/3423 and https://github.com/brianc/node-postgres/compare/pg%408.14.1...pg%408.15.1.

I downgrade the pg dependency to "pg": "8.14.1" and it works too

force version "pg": "8.11.3" (in my packages dependencies) made it start working