• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer
  • Home
  • Java Tutorial
  • Java Posts
  • Node.js
  • Spring Core
  • Algorithms
  • Docker
  • Blogging
  • Misc
Tech Stack Journal

Tech Stack Journal

package.json

If you want to ship your code from local to test or production environment, you don’t have to bundle the dependent modules along with your code. You can define all the dependent modules along with their versions in package.json file.

// File name: package.json
{
  "name": "project1",
  "version": "0.1.0",
  "dependencies": {
    "express": "4.16.3"
  }
}

Once you do this, npm takes care of downloading and installing the modules mentioned the package.json wherever you want to install your application with below command.

npm install

Addition to the modules mentioned in package.json, npm also install transitive dependencies too, that is, dependent modules of your application dependencies. You can find these dependencies in package-lock.json file.

Semantic Versioning

npm uses semantic versioning for all of its modules.

"express": "4.16.3"

In our package.json file, we have listed module express as our dependency. We specifically wanted 4.16.3 version of express module. Here 4 is major version, 16 is minor version and 3 is patch version. Either of these versions will be incremented when there is a change release.

Patch release

Patch release doesn’t introduce significant change to module. It may include some bug fixes. So even if you upgrade this module in your application, it will not break anything, that means it is backward compatible.

Minor release

Minor release might introduce new features to the module. So, here too, nothing breaks if you upgrade this module in your application as this release too is backward compatible.

Major release

Major release might make a significant change to the module. It may break your application if you upgrade to it. So, you have to be cautious and read the documentation before attempting for this migration.

Versioning using Ranges

To use latest available versions, you may include version ranges.

Version RangeInstalls any latest available version between
"express": "~4">=4.0.0 and <5.0.0
"express": "~4.16">=4.16.0 and <4.17.0
"express": "~4.16.3">=4.16.3 and <4.17.0
Versioning using ranges

Primary Sidebar

More to See

Arrays.asList in Java Examples

February 21, 2021 By Admin

[Solved] Why List.add throws UnsupportedOperationException in Java?

February 20, 2021 By Admin

Secondary Sidebar

  • Node.js Tutorial
    • Introduction to Node.js
    • Modules
    • package.json
    • Blocking and Non-Blocking Code
    • Events using EventEmitter
    • Streams – Readable Stream, Writable Stream, Duplex Stream and Transform Stream

Categories

  • Algorithms
  • Blogging
  • Docker
  • Java
  • Misc
  • Node.js
  • Spring Core
  • Windows

Archives

  • February 2021 (6)
  • January 2021 (1)
  • December 2020 (1)
  • September 2020 (2)
  • August 2020 (5)
  • July 2020 (4)
  • June 2020 (1)
  • May 2020 (4)
  • April 2020 (22)
  • November 2019 (3)
  • September 2019 (2)
  • August 2019 (6)

Footer

Navigation

  • Home
  • Java Tutorial
  • Java Posts
  • Node.js
  • Spring Core
  • Algorithms
  • Docker
  • Blogging
  • Misc

Recent

  • How to Make File Explorer Open to This PC instead of Quick Access in Windows 10
  • Arrays.asList in Java Examples
  • [Solved] Why List.add throws UnsupportedOperationException in Java?
  • How to Convert an Array to List in Java?
  • How Many Spaces in a Tab?

Search

Copyright © 2021 · Tech Stack Journal · Log in