Railgun-Community / waku-broadcaster-client

MIT License
0 stars 3 forks source link

not able to start client #2

Open deviantart414 opened 1 year ago

deviantart414 commented 1 year ago

am not able to start RailgunWakuRelayerClient using typescript. am able to import and use all other railgun repos.

Error [ERR_REQUIRE_ESM]: require() of ES Module /.../node_modules/@railgun-community/waku-relayer-client/dist/index.js from /.../test.ts not supported.

steps to reproduce

1) create new directory and yarn init 2) yarn add @railgun-community/waku-relayer-client 3) create file test.ts with code below 4) run ts-node test.ts

import { RailgunWakuRelayerClient } from '@railgun-community/waku-relayer-client'

async function main(){
    const chain = {type: 0, id:  1}
    const relayerOptions = {pubSubTopic: '/waku/2/default-waku/proto', wakuDirectPeers: []}

    await RailgunWakuRelayerClient.start(
        chain,
        relayerOptions,
        (chain, status) => console.log(status),
    )
}

main().then(console.log).catch(console.error)

Using node v18 and ts-node v10

A sample script importing/using both @railgun-community/waku-relayer-client and @railgun-community/quickstart would be helpful.

therealjmj commented 1 year ago

Your environment needs to support ESM to run this code.

It'll be modifying tsconfig and possibly using ts-node/esm. To be honest, I'm not very familiar with the setup. Every environment is different and it's typically guess-and-check with various config settings until it runs.

deviantart414 commented 1 year ago

with esm enabled I get another error on import

>> ts-node-esm index.ts 

.config/yarn/global/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:366
    throw new ERR_MODULE_NOT_FOUND(
          ^
CustomError: Cannot find module 'testrailgun/node_modules/@railgun-community/waku-relayer-client/dist/railgun-waku-relayer-client' imported from testrailgun/node_modules/@railgun-community/waku-relayer-client/dist/index.js
deviantart414 commented 1 year ago

@therealjmj can you please provide an example setup? I have tried everything can not get this module to import successfully