Importing "@terra-money/terra.js" throws Uncaught TypeError (Failed to resolve module specifier)

I want to work with this sample code from the Terra.js repo that I put in a file called 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()}`);
});

But when I want to call the script functions via index.html

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

... I get this error:

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

Can somebody point me in the right direction? Thanks a lot!


Have you installed the module through npm package manager? npm install @terra-money/terra.js