javascript - 海洋协议反应教程 npm 启动失败
问题描述
我只是想克隆这个 repo:https ://github.com/oceanprotocol/react-tutorial
当我运行应用程序时,我得到以下堆栈跟踪:
Uncaught TypeError: Cannot convert undefined or null to object
at Function.getPrototypeOf (<anonymous>)
at Object../node_modules/whatwg-url/dist/utils.js (utils.js:48)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/whatwg-url/dist/URL.js (URL.js:4)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/whatwg-url/webidl2js-wrapper.js (webidl2js-wrapper.js:3)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/whatwg-url/index.js (index.js:3)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/@oceanprotocol/squid/dist/node/aquarius/Aquarius.js (Aquarius.ts:1)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/@oceanprotocol/squid/dist/node/ocean/Ocean.js (Ocean.ts:11)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/@oceanprotocol/squid/dist/node/squid.js (squid.ts:4)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Module../src/index.js (asset.js:54)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object.1 (index.js:126)
at __webpack_require__ (bootstrap:784)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1
我在解开问题的根本原因方面运气不佳,感谢您提供任何帮助!
解决方案
看起来本教程使用的包现在已删除。(鱿鱼.js )
以及为什么它给出的TypeError
原因whatwg-url
是 squid.js 的依赖包,并且whatwg-url
期望一个对象及其接收未定义或空值。可能是 squid.js 在内部调用了一些外部 url/api 来创建实例。
而不是使用:
import { Ocean } from '@oceanprotocol/squid'
.
用这个 :
react-tutorial repo 尚未更新以支持 V3 版本的海洋协议:https ://github.com/oceanprotocol/react-tutorial/issues/14
import { Ocean } from '@oceanprotocol/react'
NPM:npm install @oceanprotocol/react
https ://www.npmjs.com/package/@oceanprotocol/react
Github 文档:https ://github.com/oceanprotocol/ocean.js
希望这可以帮助 !!干杯。
推荐阅读
- android - 如何将 Windows 笔记本电脑中编写的 python 代码传输到三星安卓手机?
- excel - 如何复制活动工作表并将其附加到没有文件夹名称的电子邮件中
- string - Rust:无法将整数解析为字符串,ParseIntError
- python - 无法从 POST 表单中获取信息
- javascript - 使用 scrollMagic 从右向左滑动动画
- linux - 要求与包含在 yocto 中
- node.js - 使用 node.js 作为后端路由角度组件的最佳方法是什么
- java - 使用 iText5 将迪拜字体中的阿拉伯字符从 html 内容转换为 pdf
- python - 获取特定扩展的所有完整路径
- sql-server - Microsoft SQL Server 无法加载简单的 CSV 文件