Cannot find module 'pg-native'
tahv0 opened this issue ยท 11 comments
Getting this warning message when importing the package with commonjs
const createPostgresSubscriber = require('pg-listen')
Getting console message: Cannot find module 'pg-native'
Everything seems to be working though. Maybe some problem in dependencies?
Using version pg-listen@1.2.0
I fear there is too little information to debug it from here.
You can try the following, though:
- Set the
native
option explicitly tofalse
- Grep for
native
in your project and check what it finds
Can you find any time to look into this?
Have a nice weekend!
I'm having the same issue as well by doing npm install pg pg-listen
in an empty directory and creating a test file with just require('pg-listen')
in it.
EDIT: I cloned and installed pg-listen
and ran index.js
in the root directory and it results in the same issue. I traced through the code and the issue is in ./dist/index.js
line var pg = __importStar(require("pg"));
. Looks like it has to do with how TypeScript converts import * as pg from "pg";
I found a similar open issue in sequelize and it seems like simply accessing pg.native will cause this issue which is what ends up happening inside __importStar
. There's if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
where mod is pg and k is 'native'
The issue was introduced with this PR because I tried reverting that change going back to import pg from "pg"
and I was no longer getting the the message. But I don't know if you'd want to revert that PR just to address this issue, since it's not really a problem.
+1 here
const subscriber = createSubscriber({
connectionString: process.env.POSTGRES_URL
}, {
native: false
})
====> Cannot find module 'pg-native'
Haha, I think I found it!
Seems to be a rather widespread issue with pg
: See sequelize/sequelize#3781 (comment).
I suspect this line to trigger it: https://github.com/andywer/pg-listen/blob/master/src/index.ts#L72
Will have a look at it later today and release a patch!
Fix is published as v1.2.1 ๐
Is this really fixed? I'm still seeing this in v5.8.5 (node v11.15.0):
Cannot find module 'pg-native'
Require stack:
- /Users/damz/Desktop/setabeautyhome/node_modules/pg/lib/native/client.js
- /Users/damz/Desktop/setabeautyhome/node_modules/pg/lib/native/index.js
- /Users/damz/Desktop/setabeautyhome/node_modules/pg/lib/index.js
@damianobarbati v5.8.5
of what? The pg-listen
version would be important to know ๐
Btw, are you sure that this is not caused by some other code? I don't see any hint about pg-listen
in the stack trace.
Ops! @andywer sorry, I thought I was in sequelize repo... ignore this ๐คฆ๐ปโโ๏ธ