Cannot find module 'bun' in Tanstack monorepo
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Router
Describe the bug
I can't import any bun libraries like s3, redis, hashing/crypto, etc in my Tanstack monorepo project. I get the error: "Cannot find module 'bun'". I have tested both in server action files, as well as a s3 package which gets imported into the web project.
Your Example Website or App
https://github.com/DeckardGer/bun-tanstack-test
Steps to Reproduce the Bug or Issue
- bun install
- bun run dev
- Navigate to localhost:3001/api/bun-test
- Look in server logs for error
Expected behavior
I should be receiving a hash created using the hash library from bun
Screenshots or Videos
Platform
- Router / Start Version: 1.141.1
- OS: MacOS
- Browser: Arc
- Browser Version: 1.140.0
- Bundler: Vite
- Bundler Version: 7.0.2
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and follow the reported steps: run bun install, bun run dev, then visit localhost:3001/api/bun-test and inspect the server logs. Compare the server action and imported S3 package cases, and verify the fix by confirming the Bun hashing library returns a hash without the “Cannot find module 'bun'” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, typescript, vite
- Domain
- backend, build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100