-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server Error ReferenceError: Cannot access 'TwitterApiReadWrite' before initialization [bug] #531
Comments
did you find the issue with this? |
up |
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)
} |
Same here, using next.js server actions.
|
Hello, This library is not actively maintained since Elon takeover, however, we accept PRs! Any idea in what version it started though? |
Hi @PLhery, Damn, that’s sad. PR about improvement? I’ll inspect and see when it started. |
getting the same issue |
Did this ever get resolved? have same issue |
Also running into this with my NextJS project |
Running into same problem with nextjs 14 server actions. Any solutions? |
I have found the issue. It's a problem with bundling. Specifically turbo. If you're using nextjs and you're builing with
|
Just to confirm @ninsau's solution worked for me! Thanks for the suggestion |
I can confirm in nextjs 15 using turbopack causes that issue. Removing --turbopack did the trick. Thank you @ninsau |
It looks like there's an actual fix in PR but needs to TS updates : #544 Who's the author here? All i see is the integration bot |
Actually, I asked an AI SWE agent (devin) to fix the issue see if it leads to somewhere. But it did not do the right thing, closing the PR. I think for now not using |
anyone figure out a way to get it to work while not losing turbo? |
add "twitter-api-v2" to the serverExternalPackages array in your next.config.ts file |
Describe the bug
I am getting this error anytime I just import the library & do a simple call: e.g.
Version
Additional context
All of this worked really well before, not sure what's changed? My codebase is pretty much the same.
The text was updated successfully, but these errors were encountered: