← All Notes

Manual Astro setup inside a pnpm monorepo

Use this when creating a new Astro app manually inside an existing pnpm monorepo, especially when avoiding Astro’s project creator because of pnpm’s minimumReleaseAge policy.

Assumption: the monorepo already has a root pnpm-workspace.yaml, for example:

packages:
  - "apps/*"
  - "packages/*"

minimumReleaseAge: 10080

10080 means 7 days.

1. Create the app folder

cd apps
mkdir trust-portal
cd trust-portal

2. Create package.json manually

touch package.json

Add the basic package setup:

{
  "name": "@ulubit/trust-portal",
  "version": "0.0.1",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  }
}

name is used by pnpm for workspace filtering.

private: true because these are deployable apps, not packages intended to be published.

3. Add Astro with pnpm

From inside the app folder:

pnpm add astro
pnpm update astro

pnpm add astro adds Astro to this app’s package.json.

pnpm update astro refreshes Astro to the newest version allowed by the existing dependency range and the monorepo’s minimumReleaseAge policy.

Later, after the app has more dependencies, use pnpm update to update all dependencies in the current. or pnpm --recursive update from the monorepo root.

4. Create the minimum Astro files

mkdir -p src/pages
touch src/pages/index.astro
touch astro.config.mjs
touch tsconfig.json

astro.config.mjs:

import { defineConfig } from 'astro/config'

export default defineConfig({})

src/pages/index.astro:

---
---

<h1>Trust Portal</h1>

tsconfig.json:

{
  "extends": "astro/tsconfigs/strict",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  }
}

5. Run the app

From inside the app:

pnpm dev

Or from the monorepo root:

pnpm --filter @ulubit/trust-portal dev

Root-level equivalent

If running from the monorepo root instead of inside the app folder:

pnpm --filter @ulubit/trust-portal add astro
pnpm --filter @ulubit/trust-portal update

The app’s package.json must already exist before using the filter.

To update dependencies across all workspace apps/packages:

pnpm --recursive update

Use the recursive update only when the target is to refresh the whole monorepo.