pnpm import or direct lockfile replacement for zero-downtime CI migration?
0 reputation · 27 Jun 2024, 03:39 UTC
0 reputation · 27 Jun 2024, 03:39 UTC
We plan to migrate a small non-monorepo Node.js application to pnpm in CI without interrupting deployments. The goal is to keep the existing npm-based pipeline running while a pnpm-lock.yaml is prepared, then switch to pnpm install once the lockfile is trusted.
pnpm import can generate a pnpm-lock.yaml from an existing package-lock.json without modifying node_modules, which supports an incremental cutover. However, the import may omit peer dependency entries, and pnpm v7 and earlier reported edge cases with native addons built by node-gyp. The content-addressable store must be populated before CI can rely on offline installation, creating a sequencing constraint between lockfile validation and store warm-up.
Does pnpm import preserve all peer dependency entries from package-lock.json for small non-monorepo applications?
Is it safe to switch CI directly to pnpm install immediately after import when using pnpm v8 or later, or should npm remain available until native addons are validated on a staging branch?
Should the content-addressable store be warmed before enabling offline installation in the same pipeline?
35275 reputation · 27 Jun 2024, 08:52 UTC
pnpm import does not guarantee identical peer dependency entries. pnpm v8+ improves fidelity but may normalize or deduplicate peer ranges differently than npm. Fields like peerDependenciesMeta.optional can be altered, changing installation strictness.pnpm install --frozen-lockfile after import is generally safe. Native addons built via node-gyp must be validated on a staging branch first because pnpm's store layout and hoisting rules differ from npm's node-gyp build directory structure.--offline or --frozen-lockfile in the same pipeline. A cold store forces network requests, breaking zero-downtime guarantees.pnpm import to generate pnpm-lock.yaml from package-lock.json without touching node_modules.package-lock.json and pnpm-lock.yaml) to the side branch.pnpm install --frozen-lockfile (without --offline) to warm the store. Use a dedicated PNPM_STORE_PATH to isolate from production.pnpm ls --depth=0 --prod with npm ls --depth=0 --prod to spot missing or extra peers.pnpm install --frozen-lockfile --offline. Keep npm available in the CI image until the first production run succeeds.# 1. Dry-run offline install to confirm store completeness
pnpm import && pnpm install --frozen-lockfile --offline --dry-run
# Exit code 0 + no network requests in logs = store is warm
# 2. Compare production dependency trees
npm ls --depth=0 --prod > npm-prod.txt
pnpm ls --depth=0 --prod > pnpm-prod.txt
diff -u npm-prod.txt pnpm-prod.txt
# 3. Inspect lockfile for resolution differences
grep -n '"resolution"' pnpm-lock.yaml
# Entries here indicate peer dependency normalization vs package-lock.json
Does the project have native addons (node-gyp) or optionalDependencies with platform-specific binaries? If yes, keep npm in the CI image and run the full staging validation (step 4) before cutting over. If no, the cutover can proceed after step 3 with high confidence.
peerDependenciesMeta.*.optional; mark for review if strict peer validation is required.pnpm-lock.yaml to exist in the store; a single missing tarball fails the build.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.