TanStack / TanStack/router

Cannot find module 'bun' in Tanstack monorepo

Open
#7,079 1 comment 1 reaction 0 assignees View on GitHub

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
  1. bun install
  2. bun run dev
  3. Navigate to localhost:3001/api/bun-test
  4. Look in server logs for error
Expected behavior

I should be receiving a hash created using the hash library from bun

Screenshots or Videos
Image
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.