Migrate the monorepo from YARN or npm to pnpm. This migration enforces strict dependency management by fixing ghost dependencies individually, updating Dockerfiles, and migrating GitHub Actions.
- Do not commit any changes to git without explicit instruction.
- Prefer
pnpm add/pnpm add -Dwhen adding dependencies to preserve lockfile integrity. - Keep
npm install -gwhen installing global packages in Dockerfile and/or GitHub Workflows. Never replace it withpnpm add -g. - Ensure all commands using
yarnare replaced with theirpnpmequivalents. ie.yarn workspace->pnpm --filter,yarn build->pnpm build, etc. - never use
pnpm@latest, always try to use the same version as specified in the rootpackage.jsonfile usingcorepackwithout version.
Only in case the node version in .node-version is < 20.19.5, upgrade Node.js to version 20.20.0. Search all project files for version references and ensure the correct runtime is installed if it is not already present.
-
Add
.pnpm-storeto .gitignore if not present. -
Run
npx --yes @pagopa/dx-cli codemod apply use-pnpmand wait for it to complete. IMPORTANT: do not skip this step. If codemod fails, stop immediately and report the issue with the error message.
This will install pnpm and create a pnpm-lock.yaml file at the root of the monorepo.
Modify all Dockerfiles to install pnpm (same version as in root package.json using corepack when possible) and use pnpm dlx turbo and pnpm install --frozen-lockfile. Prefer to use corepack (without version) to install pnpm instead of installing it via npm: pnpm version is specified in the root package.json file.
Check docker-compose.yaml files for any references to yarn and update them to use pnpm accordingly.
Ensure npm install -g (for global packages) is NEVER replaced with pnpm add -g, keep it as is.
Update workflows in .github/workflows/ to use pnpm using corepack, set cache: "pnpm", and replace yarn commands.
Prefer to use corepack (without version) to install pnpm instead of installing it via npm: pnpm version is specified in the root package.json file.
Ensure that the cache-dependency-path in GitHub Actions points to pnpm-lock.yaml to ensure reliable caching after the migration.
Execute pnpm install and pnpm -r build. For every "module not found" error, explicitly add the missing dependency until all builds succeed without using public-hoist-pattern.
Peer Dependency Issues: pnpm is strict about peer dependencies; some packages might require pnpm.peerDependencyRules in the root package.json if upstream packages have poorly defined peers.
Remove any remaining references to yarn in .gitignore
Grep for yarn in all project files and take appropriate action to remove or replace them with pnpm.
Upgrade vscode settings and all README.md to reflect changes.
Remove dependency-check from devDependencies and eliminate any related build scripts in all package.json files.
IMPORTANT: once done, run pnpm build and pnpm code-review at the root of the monorepo and fix any issues until everything pass successfully. Do not skip this step and ensure all tests are green.