How can I force npm to always generate package-lock.json with lockfileVersion 1?

npm v7 regenerates package-lock.json with lockfileVersion 2, causing issues for npm v6. e.g.,

const npmSettings = { lver: 1 };
console.info(npmSettings);

Align npm versions across the team.

i faced the same issue - npm v7 won’t let you force lockfileVersion 1. best bet is to have everyone stick to npm v6 via nvm or similar tool. it’s annoying but consistency is key on these projects.

I have been facing this issue on a project where determining the correct lockfile version was critical as not everyone was update with newer npm versions. In my practical experience, forcing npm v7 to produce package-lock.json with lockfileVersion 1 isn’t directly supported as the tool has evolved its mechanism. I eventually resorted to coordinating the npm version across teams to maintain consistency in the lockfile. Switching to npm v6 or using tools like nvm to align versions has proven effective in managing such compatibility issues.

The inability of npm v7 to produce package-lock.json with lockfileVersion 1 directly has been a notable hurdle in my experience. In one of my projects, the greatest challenge was synchronizing teams that used older versions of npm. Eventually, I resorted to using environment management tools to lock everyone into npm v6 temporarily until a full migration was feasible. Another interim solution I explored was creating a post-install script to downgrade the lockfile, but it introduced additional maintenance overhead that rendered it less attractive than a coordinated version policy.