web3 - 如何将 web3 从 esm.sh 导入 deno ./deps.ts 文件?
问题描述
url https://esm.sh/web3返回:
/* esm.sh - web3@1.6.0 */
export * from "https://cdn.esm.sh/v54/web3@1.6.0/es2021/web3.js";
export { default } from "https://cdn.esm.sh/v54/web3@1.6.0/es2021/web3.js";
但是我如何获得一个web3
对象?
import { web3 } from './deps.ts'
$ deno run --allow-all --unstable index.ts
Check file:///Users/me/www/gas/index.ts
error: TS2614 [ERROR]: Module '"file:///Users/me/www/gas/deps.ts"' has no exported member 'web3'. Did you mean to use 'import web3 from "file:///Users/me/www/gas/deps.ts"' instead?
import { web3 } from './deps.ts'
~~~~
at file:///Users/me/www/gas/index.ts:1:10
如果我这样做:import web3 from './deps.ts';
我得到这个:
$ deno run --allow-all --unstable index.ts
Check file:///Users/me/www/gas/index.ts
error: Uncaught TypeError: Cannot read properties of undefined (reading 'Rand')
at new u (https://cdn.esm.sh/v54/miller-rabin@4.0.1/es2021/miller-rabin.js:2:911)
at https://cdn.esm.sh/v54/diffie-hellman@5.0.3/es2021/diffie-hellman.js:2:1109
at https://cdn.esm.sh/v54/diffie-hellman@5.0.3/es2021/diffie-hellman.js:2:627
at https://cdn.esm.sh/v54/diffie-hellman@5.0.3/es2021/diffie-hellman.js:2:11075
at https://cdn.esm.sh/v54/diffie-hellman@5.0.3/es2021/diffie-hellman.js:2:627
at https://cdn.esm.sh/v54/diffie-hellman@5.0.3/es2021/diffie-hellman.js:2:11635