NestJs 无法使用 pg 库

问题描述 投票:0回答:1

我尝试添加以下 webpack 配置,但它似乎根本不起作用:

import webpack from 'webpack';

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

    return config;
  },
};

我正在使用 Nest.js v9.4.2,我想在我的项目中使用 pg v8.6.0 库,但是当我将其添加到

package.json
时,我收到以下错误:

 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.
javascript npm nestjs cloudflare pg
1个回答
0
投票

如果有人再次遇到此问题,您可以访问此讨论:https://github.com/vercel/next.js/discussions/50177

简单来说:

  1. 修改配置
/** @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. 转到较低版本,
    the problem is within 8.11.0 version, so you can use 8.10.0 version instead
© www.soinside.com 2019 - 2024. All rights reserved.