Simple Monorepo Starter
This is a simple monorepo starter for a project that has multiple packages. It uses PnPm for efficiency and speed
The code came mainly from Scott Tolinski's Monorepos with Pnpm tutorial.
How to use
- Click the green "Use this template" button above to create a new repo from this template
- Name your new monorepo
- Enjoy!
The packages
folder is where you'll put your packages, duh. A package can be anything from a frontend framework to a backend framework to a library to a CLI tool. It's up to you!
Scripts
"scripts": {
"start:main": "pnpm -F @project-name/main start",
"start:second": "pnpm -F @project-name/second start",
"start": "pnpm -r start",
"update:all": "pnpm -r update -i -L",
"clean": "find ./ -name node_modules -type d -exec rm -rf {} +"
},
start:main
- starts the main packagestart:second
- starts the second packagestart
- starts both/all packagesupdate:all
- recursively updates all dependencies for all packagesclean
- removes allnode_modules
folders
How to add new dependencies
# Add a new package
pnpm -F @project-name/second add just-snake-case@3.0.0
# Add a new dependency to the main package (the root package) - rarely needed
pnpm add -w just-kebab-case
How to add a new package
Simply create a new folder in the packages
folder and add run pnpm init
in that folder.
- Create a new folder in the
packages
folder - Run
pnpm init
in that folder - Optionally, duplicate
start:second
in the rootpackage.json
and change the name to the new package