@sentry库中的错误URL在React Rewired应用程序中

发布于 2025-02-08 03:11:52 字数 1735 浏览 2 评论 0原文

我目前有一个带有打字稿的React Rewired应用程序,该应用程序正在编译,但由于来自Node_modules文件夹而无法解决的3个错误。

Compiled with problems:X

ERROR in ./node_modules/@sentry/node/esm/integrations/utils/http.js 126:38-41

export 'URL' (imported as 'URL') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)


ERROR in ./node_modules/@sentry/node/esm/integrations/utils/http.js 127:39-42

export 'URL' (imported as 'URL') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)


ERROR in ./node_modules/@sentry/node/esm/transports/base.js 90:53-60

export 'URL' (imported as 'url') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)

该项目是带有智能合约的Web3项目。我正在使用Hardhat,我已经看到@Sentry是依赖性。

这是我当前的config-overrides.js:


/* eslint-disable node/no-extraneous-require */
/* eslint-disable node/no-unpublished-require */
const webpack = require("webpack");

module.exports = function override(config) {
  const fallback = config.resolve.fallback || {};
  Object.assign(fallback, {
    path: false,
    domain: false,
    console: false,
    zlib: false,
    crypto: false,
    stream: false,
    assert: false,
    http: false,
    https: false,
    os: false,
    constants: false,
    vm: false,
    fs: false,
    module: false,
    child_process: false,
    net: false,
    repl: false,
    async_hooks: false,
    tls: false,
    perf_hooks: false,
    util: false,
  });
  config.resolve.fallback = fallback;

  config.plugins = (config.plugins || []).concat([
    new webpack.ProvidePlugin({
      process: "process/browser",
      Buffer: ["buffer", "Buffer"],
    }),
  ]);
  return config;
};

关于如何解决问题的任何想法?

I currently have a React Rewired App with Typescript which is compiling but has 3 errors that I can't manage to resolve due to being from the node_modules folders.

Compiled with problems:X

ERROR in ./node_modules/@sentry/node/esm/integrations/utils/http.js 126:38-41

export 'URL' (imported as 'URL') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)


ERROR in ./node_modules/@sentry/node/esm/integrations/utils/http.js 127:39-42

export 'URL' (imported as 'URL') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)


ERROR in ./node_modules/@sentry/node/esm/transports/base.js 90:53-60

export 'URL' (imported as 'url') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)

The project is a Web3 project with smart contracts. I'm using hardhat, and I have seen that @sentry is a dependancy.

This is my current config-overrides.js:


/* eslint-disable node/no-extraneous-require */
/* eslint-disable node/no-unpublished-require */
const webpack = require("webpack");

module.exports = function override(config) {
  const fallback = config.resolve.fallback || {};
  Object.assign(fallback, {
    path: false,
    domain: false,
    console: false,
    zlib: false,
    crypto: false,
    stream: false,
    assert: false,
    http: false,
    https: false,
    os: false,
    constants: false,
    vm: false,
    fs: false,
    module: false,
    child_process: false,
    net: false,
    repl: false,
    async_hooks: false,
    tls: false,
    perf_hooks: false,
    util: false,
  });
  config.resolve.fallback = fallback;

  config.plugins = (config.plugins || []).concat([
    new webpack.ProvidePlugin({
      process: "process/browser",
      Buffer: ["buffer", "Buffer"],
    }),
  ]);
  return config;
};

Any idea on how to fix the issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灰色世界里的红玫瑰 2025-02-15 03:11:52

答案在这里 https://stackoverflow.com/a/a/a/67298289/16124812,
URL无需进口。

对我而言,从“ url”中删除陈述导入URL;解决了问题

The answer is over here https://stackoverflow.com/a/67298289/16124812,
URL need not be imported.

For me removing statement import URL from "url"; solved the issue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文