Node-postgres: Cannot find module 'pg-native' - regression [email protected]

Created on 7 Nov 2020  路  4Comments  路  Source: brianc/node-postgres

Commit in version [email protected]
https://github.com/brianc/node-postgres/commit/a02dfac5ad2e2abf0dc3a9817f953938acdc19b1

"peerDependenciesMeta": {
    "pg-native": {
      "optional": true
    }
  }

Causes an error in projects that do not use the native PG client:

Cannot find module 'pg-native'
Require stack:
- .../node_modules/pg/lib/native/client.js
- .../node_modules/pg/lib/native/index.js
- .../node_modules/pg/lib/index.js

How do I fix this error?

Most helpful comment

I get this error when I use 'pg' as ECMAScript module.

package.json:
{ "type": "module" }

index.js:
import pg from 'pg'

Node.js Version: 14.15.0

Update:
I got this error after updating node.js from 14.9.0 to 14.15.0.
Also I tested 'pg' by node.js version 14.0.0 docker image and I didn't get this error.

All 4 comments

I get this error when I use 'pg' as ECMAScript module.

package.json:
{ "type": "module" }

index.js:
import pg from 'pg'

Node.js Version: 14.15.0

Update:
I got this error after updating node.js from 14.9.0 to 14.15.0.
Also I tested 'pg' by node.js version 14.0.0 docker image and I didn't get this error.

I get this error when I use 'pg' as ECMAScript module.

Yes, this my case.

I got this error after updating node.js from 14.9.0 to 14.15.0.

I think it depends on the version of the npm

Pretty sure this wasn鈥檛 caused by that change and isn鈥檛 a regression.

Duplicate of #2387

Was this page helpful?
0 / 5 - 0 ratings