PLhery / node-twitter-api-v2

Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
https://www.npmjs.com/package/twitter-api-v2
Apache License 2.0
1.24k stars 174 forks source link

Server Error ReferenceError: Cannot access 'TwitterApiReadWrite' before initialization [bug] #531

Open dominik-sfl opened 1 month ago

dominik-sfl commented 1 month ago

Describe the bug I am getting this error anytime I just import the library & do a simple call: e.g.

let res = await client.v2.tweet("Hello");

Version

Additional context All of this worked really well before, not sure what's changed? My codebase is pretty much the same.

wang4621 commented 3 weeks ago

did you find the issue with this?

adfdev commented 1 week ago

up

Adebesin-Cell commented 1 week ago

I'm getting same issue


    const client = new TwitterApi({
      appKey: env.TWITTER_CONSUMER_KEY,
      appSecret: env.TWITTER_CONSUMER_SECRET,
      accessToken: env.TWITTER_ACCESS_TOKEN,
      accessSecret: env.TWITTER_ACCESS_TOKEN_SECRET,
    })

    const rwClient = client.readWrite

    const tweetText = endent`Hello World!`

    try {
      const result = await rwClient.v2.tweet(tweetText)
      console.log('Tweet posted successfully:', result)
    } catch (error) {
      console.error('Error posting tweet:', error)
    }
clement-faure commented 6 days ago

Same here, using next.js server actions.

const twitterClient = new TwitterApi(twitterAppBearerToken);
PLhery commented 6 days ago

Hello,

This library is not actively maintained since Elon takeover, however, we accept PRs!

Any idea in what version it started though?

Adebesin-Cell commented 6 days ago

Hi @PLhery,

Damn, that’s sad. PR about improvement?

I’ll inspect and see when it started.