6

I have understood the details from the below link but still when to use which file is a question ? https://docs.npmjs.com/files/package-lock.json

tk421
  • 5,775
  • 6
  • 23
  • 34
Vaibhav
  • 771
  • 2
  • 11
  • 23

1 Answers1

10

package.json

Contains relevant metadata for your project including dependancies, helper scripts and other general metadata.

Running npm install --save <package> or yarn add <package> adds dependancies to this file.

Between the three files listed, this is the only one you should ever need to interact with.

package-lock.json and yarn.lock

Is an auto generated file that describes the exact state of your application dependancies the last time packages where added or modified.

More specifically it guarantees the order of package installations between users - hence why it is recommended to be git committed.

yarn.lock is generated when running yarn specific commands.

package-lock.json is generated when running npm specific commands.

Matthew Mullin
  • 7,116
  • 4
  • 21
  • 35