Skip to content
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

Using 'pg' in webpack to Electron return an error trying to requiring pg-native. #1138

Closed
michaeljota opened this issue Sep 26, 2016 · 6 comments

Comments

@michaeljota
Copy link

michaeljota commented Sep 26, 2016

Hi!

I'm trying to use this bundled with webpack to be used in electron. But it tries to import the pg-native module. I really don't know how to use the native binding in Electron, but at least I would like to be able to use the plain JS driver.

I read #127 and #838, and commenting the lines mentioned here makes the package works, but I see this most like a workarround. The problem it's not gone, just hided.

Thanks!

EDIT: You can test this here

npm run build:electron

Main and Renderer process will be packaged in separated files. The Renderer part will be packaged correctly, but when it tries to bundle the Main part the error will be thrown.

@rozzzly
Copy link

rozzzly commented May 21, 2017

aaaaaaaaaaand its still not. Nor can I find any workarounds :(

@michaeljota
Copy link
Author

@rozzzly for workarounds you can comment some lines as I said in the description.

@charmander
Copy link
Collaborator

Does making pg/native part of externals in the webpack configuration work?

externals: [
    "pg/native",
],

@bkniffler
Copy link

Just tested @charmander solution with Electron, having suffered from the same issue like @michaeljota, works great! I think this should be noticed in the docs and this issue can be closed.

@evbo
Copy link

evbo commented May 17, 2020

As of pg 8.2.1, I am using this webpack config workaround, which hopefully most can stomach until a permanent fix is released:
#838 (comment)

The other thing to keep in mind is that you mustn't run postgres queries from a renderer process.

@michaeljota
Copy link
Author

Seems like this is the actual solution we need, so I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants