我尝试添加以下 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.
如果有人再次遇到此问题,您可以访问此讨论:https://github.com/vercel/next.js/discussions/50177
简单来说:
/** @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
the problem is within 8.11.0 version, so you can use 8.10.0 version instead