pnpm's workspace features enable efficient monorepo management with strict dependency isolation and shared version catalogs. Test your understanding of pnpm's most powerful workspace capabilities.
0 / 5 completed
1 / 5
What problem does pnpm's catalog feature (pnpm 9+) solve in a monorepo?
pnpm catalog (defined in pnpm-workspace.yaml under catalog:) lets you declare canonical versions once. Workspaces reference them as catalog:default instead of pinning a version string, so updating a shared dependency requires changing one line in the catalog rather than editing every package.json.
2 / 5
How does pnpm's --filter flag help when running scripts in a monorepo?
pnpm --filter scopes a command to matching workspaces. pnpm --filter @myapp/api build runs build only in the @myapp/api package. You can also use glob patterns (--filter './packages/**'), dependency selectors (--filter '...@myapp/utils' to include dependents), or changed-file filters for CI optimisation.
3 / 5
What does the shamefully-hoist option in .npmrc do in a pnpm project?
shamefully-hoist=true makes pnpm create a flat node_modules like npm, where all packages are hoisted to the root. This is called 'shameful' because it reintroduces phantom dependency problems — code can require() packages not listed in its own package.json. It exists as a migration escape hatch, not a recommended setting.
4 / 5
How do pnpm overrides (in package.json) differ from npm's overrides?
pnpm overrides are specified under the pnpm.overrides key in package.json. They force a specific version of a transitive dependency regardless of what the intermediate package requested — useful for patching security vulnerabilities in nested dependencies before upstream packages release a fix.
5 / 5
How does pnpm handle peer dependencies differently from npm in a workspace?
pnpm's peer dependency resolution uses a virtualised node_modules structure where each package gets a copy that satisfies its peers. If two workspaces depend on React 17 and React 18 respectively, pnpm creates two separate dependency sets, each with the correct React version — avoiding the singleton conflicts that flat node_modules produce.