-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when using babel, pg-native is always required (and fails if not present) #838
Comments
+1 using webpack + babel + typescript |
comment this lines in node_modules/pg/lib/index.js //lazy require native module...the native module may not have installed |
pg define getter in module.exports
when babel rewrite code, him not found __esModule property in module and make copy of module props to new hash. in copy process pg.native called unintentionally. has no idea, how to fix this
|
This might help you:
|
Any progress with this issue? |
I'm not experiencing this issue. I also using |
import pg from 'pg' does not work for me - I am seeing the pg-native error. |
@nybble73 What code generates babel for `import pg from 'pg'? Which versions? This issue can be fixed only by wrapping |
@brianc Should I prepare pull request? My suggestion is return Another option is return |
sure thing - pull request always welcome! On Wed, Feb 24, 2016 at 3:08 PM, Pavel Lang notifications@github.com
|
Still facing the same issue on |
I'm too facing it, using Webpack and AWS Lambda. |
Still having this issue bundling with webpack. Installing pg-native fixes the issue. |
I also couldn't bundle I'm also unclear if this is an issue with node-postgres or webpack. Normally webpack will resolve all dependant modules perfectly.
|
See this: serverless-heaven/serverless-webpack#78 |
I also get the same error with pg 7.4.3 using webpack and typescript.
|
Another solution (if using webpack), is to add
|
@adieuadieu 's solution worked. need to make sure you have installed webpack and imported in config file. Also, give and comma ( , ) after "plugin [ ... ]" and before "output:" npm install --save webpack
|
@brianc @amit-dhara @adieuadieu
npm@6.14.4 and Node: 12.15.0 this is the pg.js I'm using:
I also specified in webpack.config.js :
When compiling:
How to solve the problem? Marco |
This still seems to be an issue, so unsure why it was closed |
@GeorgeWL The original issue was closed with a fix. If you’re seeing something new or something that appears to be the same, please include details. |
Seeing the same, using this alongside webpack, webpack fails to correctly compile it when using TypeScript. The workaround of adding pg-native to a webpack ignorePlugin still seems to fix it. |
I think the original issue asks about babel, which seems to be still an issue. E.g. when using
|
Nothing worked for me, so I created a manual fix myself create a fix.js file at the root of the project:
to run the patch file whenever you update or install a new dependency, add it to the package.json file:
If you are using sequelize, make the following configuration in the configuration part:
|
@antonycms thanks so much! struggled with this issue and your solution works like a charm! |
An alternative workaround is to create a local pg-native package and reference it from your package.json
The
and a basic
|
is this actually fixed? or has it been closed due to workarounds? |
|
that's not a fix, that's a workaround. keyword: optional |
¯\_(ツ)_/¯ anything that unblocks me is a fix. |
Just in case anyone is using
|
The old api of using a getter to require the native bindings was not a good idea, but it's been around for ages and ages. Unfortunately it's a backwards compatiblity break to change it but one I'm happy to do - I've put this into the 9.0 milestone so it'll go out w/ our next major version release where we break backwards compatibility. |
Here is a workaround if you are using webpack pg-native.js module.exports = null; webpack.config.js ...,
resolve: {
alias: {
'pg-native': path.join(__dirname, 'pg-native'),
},
},
..., |
nice it‘s worked for me thx @antonycms |
@sdegroot |
I added following in my webpack config to workaround the issue, new IgnorePlugin({
resourceRegExp: /^pg-native$/,
contextRegExp: /./,
}), |
Thank you!!! Easiest way to do it, no webpack required. |
I'm not sure if this is a Babel or a node-postgres bug, steps to reproduce:
Babel generates the following code in
t-es5.js
:The exception is happening in the
_interopRequireWildcard(_pg)
call. This doesn't happens with other libraries, so I'm not sure if a Babel or a node-postgres bug.The text was updated successfully, but these errors were encountered: