How to fix: pg-promise can't resolve pg-native

17 November, 2018

I ran into this issue while building the GraphQL resolvers for OnlineOrNot: pg-promise can't resolve pg-native.

Basically when you build for production, Webpack can’t find the pg-native library (which is an optional include!).

The fix is to add new webpack.IgnorePlugin(/^pg-native$/) to your Webpack config’s plugins array:

const webpackConfig = {
  ...
  resolve: { ... },
  plugins: [
    new webpack.IgnorePlugin(/^pg-native$/)
  ]
  output: { ... }
  ...
}

Enjoyed this post? Receive the next one in your inbox!


Previous: Ideas for testing and monitoring GraphQL servers