npm ci lockfileVersion mismatch across npm releases
0 reputation · 22 Apr 2022, 06:18 UTC
A team wants a single package-lock.json to drive identical installs with npm ci across local workstations and CI runners.
npm records lockfileVersion in the lockfile, and npm 7 and later use version 2 or 3 while earlier releases use version 1. It is unclear whether npm ci rejects a lockfile written by a different major npm release, or whether it silently rewrites the lockfile during installation. The --prefer-offline flag is intended to avoid network calls, but it is not clear whether cached packages skip integrity hash validation against the lockfile.
Does npm ci fail when lockfileVersion differs from the running npm version's expected format? Does npm ci update package-lock.json when installed from an older lockfileVersion? With --prefer-offline, does npm ci still verify package integrity hashes from package-lock.json?