Bruhda
Bruhda

Reputation: 21

NestJs cannot use pg library

I've tried to add the following webpack config but it doesn't seems to work at all:

import webpack from 'webpack';

module.exports = {
  webpack: (config, options) => {
    config.plugins.push(
      new webpack.IgnorePlugin({
        resourceRegExp: /^pg-native$|^cloudflare:sockets$/,
      }),
    );

    return config;
  },
};

I am using Nest.js v9.4.2 and I want to use pg v8.6.0 library for my project but when I add it to the package.json I get the following error:

 Info  Webpack is building your sources...

ERROR in cloudflare:sockets
Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "cloudflare:" URIs.

Upvotes: 2

Views: 1483

Answers (1)

Osama Mohammed
Osama Mohammed

Reputation: 32

If anyone has faced this issue again, you can visit this discussion: https://github.com/vercel/next.js/discussions/50177

For brief:

  1. modify config
/** @type {import('next').NextConfig} */
const nextConfig = {
    // ...
    webpack: (config, { webpack }) => {
        config.plugins.push(new webpack.IgnorePlugin({
            resourceRegExp: /^pg-native$|^cloudflare:sockets$/,
        }))

        return config
    },
}

export default nextConfig
  1. go to lower version, the problem is within 8.11.0 version, so you can use 8.10.0 version instead

Upvotes: 0

Related Questions