I have a monorepo project using bun workspaces. I have app/web and app/api, packages/api-client, packages/shared, packages/eslint-config.
I want to install typescript, how would I go about doing this? do i install typescript in each app and package or do I use peer dependency, what's the best approach for common npm packages?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
For TypeScript and other common development dependencies in a Bun workspace monorepo, the best approach is to install them at the root level. Here's how:
Install TypeScript at the root:
bash
# From your monorepo root directory
bun add -d typescript
This installs TypeScript as a dev dependency in your root package.json. All workspaces can access it without needing their own copies.
Best practices for dependency management in monorepos:
1. Development tools at root
Install these at the workspace root:
TypeScript
ESLint
Prettier
Testing frameworks (Jest, Vitest)
Build tools
2. Runtime dependencies in individual packages
Install these where they're actually used:
React (in app/web)
Express (in app/api)
Package-specific libraries
3. Shared dependencies
For dependencies used by multiple packages:
If it's a dev dependency → install at root
If it's a runtime dependency → install in each package that needs it (Bun will deduplicate)
For packages that other projects might consume (like packages/api-client), you might want to add TypeScript as a peer dependency in addition to having it at the root, but for internal monorepo use, the root installation is sufficient.