【问题标题】:Importing "@terra-money/terra.js" throws Uncaught TypeError (Failed to resolve module specifier)导入“@terra-money/terra.js”会抛出 Uncaught TypeError(无法解析模块说明符)
【发布时间】:2022-01-26 00:32:40
【问题描述】:

我想使用来自 Terra.js 存储库的示例代码,我将其放入名为 terra-test.js 的文件中:

import { LCDClient, Coin } from '@terra-money/terra.js';

// connect to bombay testnet
const terra = new LCDClient({
  URL: 'https://bombay-lcd.terra.dev',
  chainID: 'bombay-12',
});

// To use LocalTerra
// const terra = new LCDClient({
//   URL: 'http://localhost:1317',
//   chainID: 'localterra'
// });

// get the current swap rate from 1 TerraUSD to TerraKRW
const offerCoin = new Coin('uusd', '1000000');
terra.market.swapRate(offerCoin, 'ukrw').then(c => {
  console.log(`${offerCoin.toString()} can be swapped for ${c.toString()}`);
});

但是当我想通过 index.html 调用脚本函数时

<html>
<head>
<title>Terra.js Test</title>
</head>
<body>
<script type="module" src="terra-test.js"></script>
</body>
</html>

...我收到此错误:

Uncaught TypeError: Failed to resolve module specifier "@terra-money/terra.js". Relative references must start with either "/", "./", or "../".

有人能指出我正确的方向吗?非常感谢!

【问题讨论】:

    标签: javascript blockchain terra-blockchain


    【解决方案1】:

    您是否通过 npm 包管理器安装了模块? npm install @terra-money/terra.js

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-11
      • 1970-01-01
      • 2023-02-16
      • 1970-01-01
      • 2021-09-10
      • 2019-03-07
      • 2022-11-06
      相关资源
      最近更新 更多