1

I updated NodeJS to v16, and it ships with NPM v8, so when I install packages, package-lock.json file is created with "lockfileVersion": 2. I would like to stay with old format of "lockfileVersion": 1. Can we install packages in NPM v8, but keep the version of package-lock.json to 1?

NeNaD
  • 18,172
  • 8
  • 47
  • 89
  • You are totally right, I updated question title and text. Tnx. @CherryDT – NeNaD Nov 05 '21 at 15:42
  • Does this answer your question? [Is there any way to fix package-lock.json lockfileVersion so npm uses a specific format?](https://stackoverflow.com/questions/64813775/is-there-any-way-to-fix-package-lock-json-lockfileversion-so-npm-uses-a-specific) – m90 Nov 05 '21 at 15:48
  • It does not. As you see in accepted answer, they are downgrading Node locally to do it. I am asking if I can do it with new version of Node and NPM. – NeNaD Nov 05 '21 at 16:02
  • What happens if you `npm i -g npm@6` – Joe Nov 06 '21 at 03:01
  • We handled this at a job by installing v8 and v6 back and forth using the above command, depending on project. Yay? – Joe Nov 06 '21 at 12:47
  • Yeah, I know I can do that, but I wanted to know if I can install packages with `v8`, but keep `lockfileVersion` to 1, without downgrading npm each time. – NeNaD Nov 11 '21 at 21:34

1 Answers1

1

I believe you can find thorough answers to this question at Is there any way to fix package-lock.json lockfileVersion so npm uses a specific format? . Using lockfileVersion 2 should be backwards compatible all the way back to at least NodeJS 6+ so im not sure why you would want to use version 1, but if you must there are solutions provided on the linked post.