node. js package Dependency and version number

Source: Internet
Author: User

Original: http://www.cnphp6.com/archives/64130

One of the most important files for node. JS is Package.json, where the configuration parameters determine the functionality. For example, here's an example

{  "name": "Test",  "version": "1.0.0",  "description": "Test",   "Main": "Main.js",  "keywords": [    "test"  ],  "author": "Wade" ,  " License ":" MIT ",  " dependencies ": {    " Express ":" ^4.10.1 "  },  " Devdependencies ": {    " jslint ":" ^0.6.5 "  }}

Dependencies and Devdependencies:

A node package has two dependencies, one is dependencies, and the other is devdependencies, which relies on items that are required to run the package properly, while the latter is a dependency that needs to be developed, such as a package that carries out unit tests. Simple to remember is the following

"Dependencies": {}//Production environment

"Devdependencies": {}//development environment

The modules inside the devdependencies are also installed when the NPM install is executed in the directory where the Package.json is located. If we just want to install dependencies inside the package, you can execute

NPM install–production

If you install only devdependencies, you can perform

NPM Install–dev

Similarly, the Dependencies field values are automatically updated using NPM install Node_module–save, and the Devdependencies field values are automatically updated using NPM install Node_module–save-dev.

Version number:

Each module is followed by his version number, such as "^4.10.1″." Here are a few versions of the expression

An expression Version Range
>=1.2.7 Greater than or equal to 1.2.7
>=1.2.7 <1.3.0 1.2.7,1.2.8,1.2.9
1.2.3–2.3.4 >=1.2.3 <=2.3.4
1.2–2.3.4 >=1.2.0 <=2.3.4
1.2.3–2.3 >=1.2.3 <2.4.0
1.2.3–2 >=1.2.3 <3.0.0
* >=0.0.0
1.x (equivalent to 1. X >=1.0.0 <2.0.0
1.2.x >=1.2.0 <1.3.0
"" (equivalent to *) >=0.0.0
1 (equivalent to 1.x.x) >=1.0.0 <2.0.0
1.2 (equivalent to 1.2.x) >=1.2.0 <1.3.0
~1.2.3 (>=1.2.3 <1. ( 2+1). 0) >=1.2.3 <1.3.0
~1.2 (>=1.2.0 <1. ( 2+1). 0) >=1.2.0 <1.3.0
(>=1.0.0 <). 0.0) >=1.0.0 <2.0.0
~0.2.3 (>=0.2.3 <0. ( 2+1). 0) >=0.2.3 <0.3.0
~0.2 (>=0.2.0 <0. ( 2+1). 0) >=0.2.0 <0.3.0
~0 (>=0.0.0 < (0+1). 0.0) >=0.0.0 <1.0.0
~1.2.3-beta.2 >=1.2.3-beta.2 <1.3.0
^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
^0.0.3-beta >=0.0.3-beta <0.0.4
^1.2.x >=1.2.0 <2.0.0
^0.0.x >=0.0.0 <0.1.0
^0.0 >=0.0.0 <0.1.0
^1.x >=1.0.0 <2.0.0
^0.x >=0.0.0 <1.0.0
Reference documents:

Http://stackoverflow.com/questions/22343224/difference-between-tilde-and-caret-in-package-json

Https://www.npmjs.org/doc/misc/npm-config.html#production

node. js package Dependency and version number (RPM)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.