DEV Community

Cover image for The difference between Package and Package-lock.json
Ajinkya Chanshetty
Ajinkya Chanshetty

Posted on

The difference between Package and Package-lock.json

The package.json file is the most crucial file in any application that records all other libraries and their versions. It contains all the details related to that particular application, including its name, dependencies, and dev-dependencies.

Dependencies are essential for the app to run correctly in production environments, while dev-dependencies are only required for development mode, not for production.

Package.json is the most important file of any application that keeps the record of all other libraries and its versions.

Package.json file has all the details mentioned about that particular application.

The name and dependencies and dev-dependecies are also mentioned there.

Basically dependencies are the ones that are required for the app to run properly in the production environments and dev-dependencies are essentials which are required for the development mode only not for the prod one.

For example, testing packages are not required on production but only for dev mode.

Package json has the versions of the supportive libraries mentioned at the time of first creation of the app.

Package-lock.json has actual versions of the libraries present currently.

Ex. react-router: “^3.4.5” is mentioned in package will download the minor version update so lock file can have 3.5.0 but not 4.x and if ~ is mentioned means the third digit can be updated of the version. Similarly for the * the major release can be updated.

So, all these updated versions are mentioned in the package-lock.json

  • Patch releases: 1.0 or 1.0.x or ~1.0.4
  • Minor releases: 1 or 1.x or ^1.0.4
  • Major releases: * or x

Thus we can define the exact version as per our convenience.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay