首页 > 解决方案 > 在我的情况下,我得到:app.js:1 Uncaught ReferenceError: require is not defined

问题描述

对于我的示例,我找不到任何解决方案。

应用程序.js:

 const TronWeb = require("tronweb");


const tronWeb = new TronWeb({
    fullHost: "https://api.shasta.trongrid.io"
});


const publicAddress = tronWeb.defaultAddress.base58

console.log(publicAddress);

索引.html:

    <script src="tronweb.js"></script>
    <script src="app.js"></script>

localhost/index.html 我得到了错误。 在终端节点 app.js 中使用“我想在页面 index.html 中显示并且是相同的方式。也许缺少库?我试图从 github 转移,但我总是遇到同样的错误。

标签: javascriptrequiretrontronweb

解决方案


推荐阅读