Skip to content

Instantly share code, notes, and snippets.

@itsmikita
Last active January 21, 2024 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsmikita/2727e94ed874b1a9bbc518826741ecae to your computer and use it in GitHub Desktop.
Save itsmikita/2727e94ed874b1a9bbc518826741ecae to your computer and use it in GitHub Desktop.
How to create a monorepo

How to create a monorepo

  1. Create the root folder:
mkdir monorepo
  1. Create monorepo's package.json:
nano monorepo/package.json
  1. with following contents:
{
  "name": "@project/monorepo",
  "private": "true",
  "version": "0.0.0",
  "workspaces": [
    "packages/*",
    "apps/*"
  ],
  "dependencies": {
    "bun": "latest",
    "bun-types": "latest",
    "typescript": "latest"
  }
}
  1. Create workspace package folder:
mkdir -p monorepo/packages/package-a
  1. Create the package's package.json:
nano monorepo/packages/package-a/package.json
  1. With follwoing content:
{
  "name": "@project/package-a",
  "private": "true",
  "version": "0.0.0",
  "dependencies": {
    "bun": "latest",
    "bun-types": "latest",
    "typescript": "latest"
  }
}
  1. Create monorepo's app folder:
mkdir -p monorepo/apps/app-a
  1. Create the app's package.json:
nano monorepo/apps/app-a/package.json
  1. With the following content:
{
  "name": "@project/app-a",
  "private": "true",
  "version": "0.0.0",
  "dependencies": {
    "bun": "latest",
    "bun-types": "latest",
    "typescript": "latest"
  }
}
  1. Install the monorepo's dependencies by running bun install from the monorepo's root folder:
cd monorepo && bun install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment