Home  >  Article  >  Web Front-end  >  Detailed explanation of nodejs package.json example

Detailed explanation of nodejs package.json example

零下一度
零下一度Original
2017-06-30 13:17:181302browse

nodejs's package.json defines a module, including a simple JSON file of its dependencies, which can contain multiple different instructions to tell the Node package manager how to handle the module. Dependencies represents the modules and versions that this module depends on. You can often see version range indicators like ^1.2.0 or ~1.2.0.

First, a complete version number group is expressed as: [major version number, minor version number, patch version number]

1. Use ~ to indicate the range

version If the major version and minor version are specified in the number, only the patch version is allowed to be upgraded;

If only the major version is specified, the minor version and patch version are allowed to be upgraded.

~1.2.3 specifies the major and minor version, so it can be upgraded to 1.2.9

~1 specifies the major version, so it can be upgraded to 1.9.9

~1.2.3-beta.2 >=1.2.3-beta.2 < 1.3.0

(Note: Version 1.2.3 allows beta versions higher than beta.2, But 1.2.4-beta.2 is not allowed because it is a beta version belonging to another version number group)

2. Using ^ to specify the range

will not change the leftmost one. Version upgrades with non-zero version numbers, that is, ^1.0.0 allows minor and patch version upgrades, ^0.1.0 allows patch version upgrades, and ^0.0.x does not allow upgrades.

^1.2.3 >=1.2.3 < 2.0.0

^0.2.3 >=0.2.3 < 0.3.0

^0.0 .3 >=0.0.3 < 0.0.4

^1.2.3-beta.2 >=1.2.3-beta.2 < 2.0.0

Allow 1.2 .3 version is a beta version higher than beta-2.

^0.0.3-beta.2 >=0.0.3-beta.2 < 0.0.4

Only version 0.0.3 higher than beta-2 is allowed

When parsing the version range with ^, the missing patch version number will be filled with 0, but it will be handled flexibly, that is, both the major and minor version numbers can be 0.

^1.2.x >= 1.2.0 < 2.0.0

^1.x >= 1.0.0 < 2.0.0

^0.0 .x >= 0.0.0 < 0.1.0

^0.0 >= 0.0.0 < 0.1.0

^0.x >= 0.0.0 < 1.0.0

The above is the detailed content of Detailed explanation of nodejs package.json example. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn