javascript 尝试连接到Hedera网络时遇到错误,错误怎么会出现在node_modules中?

68de4m5k  于 2023-02-07  发布在  Java
关注(0)|答案(1)|浏览(90)

所以这是错误'\节点模块@散列图\sdk\lib\通道\节点通道.cjs:92 },10_000);
我只是建立了一个基本的连接来获取我的账户余额。下面是我的代码:

const { Client, AccountBalanceQuery } = require("@hashgraph/sdk");

require("dotenv").config();

async function main() {

// Grab your Hedera account ID and Key
const myAccountId = process.env.MY_ACCOUNT_ID;
const myPrivateKey = process.env.MY_PRIVATE_KEY;

// throw an error if you couldn't get the id
if (myAccountId == null || myPrivateKey == null ) {
    throw new Error("Environment variables must be present");
}

console.log("I made it this far");

// connect to the hedera network
const client = Client.forTestnet();

client.setOperator(myAccountId, myPrivateKey);


// Now the connection to the hedera network is established

// get your balance 
const balance = await new AccountBalanceQuery()
    .setAccountId(myAccountId)
    .execute(client)

console.log(`${myAccountId} balance =  ${balance.value()}`);
 }

main();
flvlnr44

flvlnr441#

你有关于你得到的错误的更详细的信息吗,我想不仅仅是一行,很难确定问题是什么。
删除node_modules并运行npm installyarn install也可能有所帮助。

相关问题