foobarF
Denoβ€’2y agoβ€’
4 replies
foobar

npm import : class is not found but it is well declared in node_module

I try to use Tatum SDK in deno (https://github.com/tatumio/tatum-js). I pick up the easiest code example https://docs.tatum.io/

I try 2 ways of imports of tatum library but I have different errors in both ways.

1. with npm

don't recognize TatumSDK in import (but in node_modules it is exported in service/tatum).
How can I tell the owner to slighty modify his code in order that TatumSDK is recognize (Ethereum, Network are recognized) ?

import { Ethereum, Network, TatumSDK } from "npm:@tatumio/tatum";

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM });
const latestBlock = await tatum.rpc.blockNumber();
console.log(`Latest block is ${latestBlock.result}`);
tatum.destroy();


2. with esm

Library BigNumber.js has a version for deno !
error: Uncaught (in promise) TypeError: R.BigNumber is not a constructor

// BigNumber.js has a version for deno !
// error: Uncaught (in promise) TypeError: R.BigNumber is not a constructor
import { Ethereum, Network, TatumSDK } from "https://esm.sh/@tatumio/tatum";

// fake call to prevent error
window.location = { hostname: "fake" };

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM });
const latestBlock = await tatum.rpc.blockNumber();
console.log(`Latest block is ${latestBlock.result}`);
tatum.destroy();
Was this page helpful?