【发布时间】:2021-07-08 00:03:45
【问题描述】:
我是一名网络开发人员,拥有很多尝试学习 solidty + react 和 IFPS 的专家。我是这里的新手!将 IPFS 连接到我的 Truffle React 项目给我带来了问题。我只是在创建一个我可以从中学习的超级简单的示例,并且我遇到了一个依赖错误(我在想这就是发生的事情),我在网上找不到任何相关信息。我创建了其他solidy+react 应用程序,但这是我第一个涉及IPFS 的应用程序。
我已将 ifps 添加到我的工作松露项目中:
npm install --save ipfs-http-client
& 现在我正在尝试在我的 App.js 中实例化 ifps 对象,如下所示:
const { create: ipfsHttpClient } = require('ipfs-http-client');
添加此行会导致我没有看到其他人在网上谈论的错误。浏览器吐槽:
TypeError: TextDecoder is not a constructor ./node_modules/multiaddr/node_modules/multibase/src/util.js
C:/devroot/Solidity/ScriptureOfTheDay/client/node_modules/multiaddr/node_modules/multibase/src/util.js:7
4 | TextEncoder = _require.TextEncoder,
5 | TextDecoder = _require.TextDecoder;
6 |
> 7 | const textDecoder = new TextDecoder();
8 | /**
9 | * @param {ArrayBufferView|ArrayBuffer} bytes
10 | * @returns {string}
这是来自 Chrome 控制台:
**util.js:7 Uncaught TypeError: TextDecoder is not a constructor**
at Object../node_modules/multiaddr/node_modules/multibase/src/util.js (util.js:7)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/multiaddr/node_modules/multibase/src/base.js (base.js:3)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/multiaddr/node_modules/multibase/src/constants.js (constants.js:5)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/multiaddr/node_modules/uint8arrays/to-string.js (to-string.js:3)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/multiaddr/src/ip.js (ip.js:5)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/multiaddr/src/convert.js (convert.js:3)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/multiaddr/src/codec.js (codec.js:3)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/multiaddr/src/index.js (index.js:3)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object../node_modules/ipfs-http-client/src/index.js (index.js:6)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Module.<anonymous> (App.js:7)
at Module../src/App.js (App.js:96)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Module../src/index.js (index.css?e32c:37)
at __webpack_require__ (bootstrap:785)
at fn (bootstrap:150)
at Object.0 (serviceWorker.js:135)
at __webpack_require__ (bootstrap:785)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1
有人有什么想法吗?我已经重新安装了 node_modules,从 stratch 开始 - 我只是一直在这里结束。 谢谢你的帮助, 克里斯B
【问题讨论】:
标签: javascript node.js reactjs truffle ipfs