javascript - JS + DharmaProtocol - 未捕获的语法错误:请求的模块“...”不提供名为“Dharma”的导出
问题描述
我正在使用 Dharma 协议构建中继器。尝试导入协议时(通过 yarn add @dharmaprotocol/dharma.js 安装)我收到错误:
Uncaught SyntaxError: The requested module
'./node_modules/@dharmaprotocol/dharma.js/dist/lib/src/index.js' does not
provide an export named 'Dharma'
我尝试将位于“node_modules/@dharmaprotocol/dharma.js/dist/lib/src/”目录中的 index.js 文件重命名为 index.mjs,希望 JS 将其识别为模块文件,但没有成功。
mint.js:
import { Dharma } from "@dharmaprotocol/dharma.js";
const provider = window.web3.currentProvider;
provider.enable();
const dharma = new Dharma(provider);
index.js:
"use strict";
/***********
* Utils *
***********/
Object.defineProperty(exports, "__esModule", { value: true });
// Allows the user to instantiate the correct version of BigNumber.js
without
// needing to add version 5.0.0 to their project.
var bignumber_1 = require("../utils/bignumber");
exports.BigNumber = bignumber_1.BigNumber;
var Web3 = require("web3");
exports.Web3 = Web3;
/***********
* Types *
***********/
var dharma_1 = require("./types/dharma");
exports.Dharma = dharma_1.Dharma;
解决方案
推荐阅读
- java - 未找到定义类:com.google.common.primitives.Longs
- r - 绘制 2 个图 - 1 个来自 NetworkD3,1 个来自绘图函数
- video - 从 JPG 创建一个视频,没有以 ffmpeg 开头的所有图片
- android - 无法检索 Firebase 实例 ID(没有 Firebase 服务正在运行)
- bash - 更新后运行脚本仍然运行旧脚本(更新前的版本)
- javascript - Webpack 5 在单独的 css 文件中编译 scss
- state - Anylogic初始化状态块
- angular - 如何确保始终了解第三方 API 的最新 API 速率限制?
- javascript - 无法单击 ReactJS Hooks 中的按钮?
- sql - 如何使用分区并保持一致性