Front-end (vue) entry to proficiency course: enter to learn
version format: XYZ[-string]
6.3.2-alpha
meaning
is
:
Backwards compatible updated iterations.
Minor version number 3, there are 3 small feature iterations. This new package can be installed for any dependency statement of 6.*.*
<= 6.3.2
.
Corrected version number 2, there are 2 bug modifications or other non-major functional modifications. This new package can be installed for any dependency statement of 6.*.*
<= 6.3.2
.
The advanced version number alpha
represents the experimental stage of processing.
Extended reading: How to identify dependency versions in semantic version 2.0.0
will be explained as follows:
"vue": "~2.5.22", "vue-class-component": "^6.0.0", "vue-router": "3.0.1", "express": "latest", "mongoose": "*",
symbol ^
: lock the main version, you can update the minor version number, revised version number and advanced version number.
For example "vue-class-component": "^6.0.0"
, you can install it when installing dependencies Any version that conforms to 6.*.*
, as long as the main version number is 6.
Symbol ~
: Lock the major version number and minor version number, and update the revised version number and prior version number,
such as "vue": "~2.5.22"
. When installing dependencies, you can install any version that conforms to 2.5.*
.
空符号
: Lock all version numbers,
such as "vue-router": "3.0.1"
, and only dependent packages with version 3.0.1
can be installed.
符号*
: Define a certain version number range,
such as vue-router": "3.0.*"
, you can install any version fixed to 3.0
, such as 3.0.1
, 3.0.2
.
latest
: install the latest stable version
For example, "express": "latest"
can install 4.18.1
(the latest version of 2022.06.13).
*
: Install the latest released version, not necessarily the stable version
For example, "mongoose": "*"
can install 6.0.0-rc2
, 3.9.7
, etc.
Git URL
: Use the package reference format published on Git
: <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
"test": "git+ssh://[email protected]:npm/cli.git#v1.0.27"
Extended reading: npm docs -
As the title says, this is an experience gained through blood lessons.
When the author uses system.js
, the version limit used is: system.js: "^6.3.2"
.
When installing dependencies, version > 6.3.2
was accidentally installed, causing project running errors.
The reason is that the author of system.js
did not name the version number according to the semver
specification, which caused the author's project to introduce an update that was not backward compatible , causing the project to run incorrectly.
used in the production environment are all installed under dependencies
.
For example:
"dependencies": { "chalk": "^2.4.2", "commander": "^3.0.0", "fs-extra": "^8.1.0", "inquirer": "^6.5.0", "mem-fs": "^1.1.3", "mem-fs-editor": "^6.0.0", "shelljs": "^0.8.3" }
The above code is a fragment from package.json
of the cli
toolkit created by the author.
shelljs
is used to operate files. If the declaration is changed to devDependencies
, an error will be reported after the user installs the current tool package.
Because the dependencies declared in the devDependencies
field will not be installed when npm install 工具包
. It must be declared in the dependencies
field before it will be installed.
Dependencies that are not needed in the production environment need to be installed under devDependencies
.
Because in a production environment, dependencies under the devDependencies
field will not be installed.
For example:
"devDependencies": { "@commitlint/cli": "^8.1.0", "@commitlint/config-conventional": "^8.1.0", "commitizen": "^4.0.3", "commitlint-config-cz": "^0.12.1", "cz-customizable": "^6.2.0", "standard-version": "^7.0.0" }
The above code is a fragment from package.json
of the cli
toolkit created by the author.
commitizen
is the dependency package used by the author to standardize Git
submission specifications. It is only used in the development environment, so it is declared in devDependencies
.
When developing some plug-ins and toolkits, there are requirements for the dependency package version of the user's running environment, which can be declared using the peerDependencies
field.
For example:
{ "name": "tea-latte", "version": "1.3.5", "peerDependencies": { "tea": "2.x" } }
The current tool tea-latte
depends on the tea
package. Moreover, the tea
package is required to be major version 2.
When the requirements are not met, the console will report an error.
Notice
npm v7 version, peerDependencies will be installed by default.
npm v3 to npm v6,peerDependencies
will not be installed automatically.