Dependency Management
Learn how to manage dependencies in Achromatic.
We chose pnpm as our package manager due to its speed and disk space efficiency.
About pnpm By using hard links and symlinks, pnpm ensures that each module version is stored only once on the disk, reducing redundancy. Additionally, it offers excellent support for monorepos, making it an ideal choice for the starter kit. It's also the preferred solution inside Vercel, the creator of Next.js.
Install all packages
To install all packages in all workspaces run:
pnpm i
This is likely your first command when you download the starter kit.
Clean workspace
To clean the whole workspace run following command:
pnpm clean:workspaces
Or alternatively in a specific workspace:
cd apps/dashboard
pnpm clean
Add a package
To install a package to the root of the monorepo, making it available to all workspaces, run:
pnpm add -w <package-name>
To install a package to a specific workspace, making it available only to that workspace, run:
pnpm add --filter <workspace-name> <package-name>
We use Syncpack and Manypkg to ensure that your packages always align with the latest version specified in the monorepo. This means if you install version 2.3 in one package.json and then attempt to install version 2.2 in another package.json, it will automatically update to version 2.3 to maintain consistency across the repo
Remove a package
To remove a package from the root of the monorepo, run:
pnpm remove -w <package-name>
To remove a package from a specific workspace, run:
pnpm remove --filter <workspace-name> <package-name>
Update a package
This step is redundant because we automatically sync the package versions. You can just update the version somewhere in the monorepo and run pnpm i
to sync. However pnpm also comes with a nice update command
pnpm update -r <package-name>