【问题标题】:Can't resolve module 'ipfs-http-client' in react-app无法在 react-app 中解析模块 \'ipfs-http-client\'
【发布时间】:2022-10-05 15:13:38
【问题描述】:

我在我的反应应用程序中遇到了 \'ipfs-http-client\' 的问题,

我正在使用节点 16.14.0

错误信息是:

当我 Ctrl + 单击 \'ipfs-http-client\' 时,它仍然将我带到模块文件。

我已经完成但不起作用的解决方案:

  • 重启应用
  • 重新安装模块

我试过使用 33.x 版本,它工作正常,但我不想使用最新版本的 \'ipfs-http-client\' (57.0.3)

请帮我。非常感谢!

    标签: node.js reactjs blockchain ipfs-http-client


    【解决方案1】:

    [编辑] 现在可以了。

    但是我不得不做很多事情..问题似乎与react使用的webpack 4有关,但由于某种原因与IPFS包不兼容..不知道为什么..

    我不得不将 react-scripts 升级到 react-scripts@5.0.1使用 npm uninstall react-scripts 和 npm install react-scripts@5.0.1。

    然后我不得不安装一些软件包使用这个 MAGIC POLYFILL TUTORIALhttps://github.com/facebook/create-react-app/issues/11756#issuecomment-1001162736

    然后我得到了一些我解决的 webpack PolyErrors使用这个 NPM 包: https://www.npmjs.com/package/node-polyfill-webpack-plugin

    我也有关于的错误无法从 source-map-loader 加载 Source-Map,这将使用包含在新 React-Scripts 中的 WebPack5 发生。您可以使用以下方法解决此问题: Failed to parse source map

    现在它可以工作了.

    这似乎是一个肮脏的黑客,但这就是我们需要的。

    这些是我的包裹:

    NPM:8.19.2

    节点:v18.10.0

    @libp2p/logger@2.0.1
    ├── @metamask/providers@9.1.0
    ├── @testing-library/jest-dom@5.16.5
    ├── @testing-library/react@13.4.0
    ├── @testing-library/user-event@13.5.0
    ├── https-browserify@1.0.0
    ├── i@0.3.7
    ├── ipfs-http-client@58.0.1
    ├── ipfs@0.64.2
    ├── node-polyfill-webpack-plugin@2.0.1
    ├── npm@8.19.2
    ├── os-browserify@0.3.0
    ├── os@0.1.2
    ├── react-app-rewired@2.2.1
    ├── react-datepicker@4.8.0
    ├── react-dom@18.2.0
    ├── react-router-dom@6.4.1
    ├── react-scripts@5.0.1
    ├── react-unity-webgl@9.2.1
    ├── react@18.2.0
    ├── recoil@0.7.5
    ├── stream-browserify@3.0.0
    ├── stream-http@3.2.0
    ├── validator@13.7.0
    ├── walletlink@2.5.0
    ├── web-vitals@2.1.4
    ├── web3@1.8.0
    └── web3modal@1.9.9
    

    [/编辑]

    我在 Windows 10 和 11 上遇到了同样的问题,但它对使用 Mac 的同事来说效果很好。我还尝试将 Node_Modules 路径添加到 Windows 中的路径环境变量,但它似乎还没有工作。也许我必须先重新启动..让我们看看 我也尝试使用 Linux 安装它,但它在那里也不起作用。使用完整路径直接导入模块时,它可以工作,但它无法从 IPFS npm 存储库中找到其他包。

    【讨论】:

      猜你喜欢
      • 2022-08-14
      • 1970-01-01
      • 2020-08-30
      • 2022-06-16
      • 1970-01-01
      • 2018-03-05
      • 2020-06-02
      • 2021-09-21
      • 2022-09-23
      相关资源
      最近更新 更多