Nodejs semantic versioning
The semantic versioning definition is followed by the json file.
You can write the syntax values in the given below.
The recommended starting version for any new package is 1.0.0.
Npm semantic versioning
The calculation of the semantic versioning is described in the next section.
1) caret or "^"
The default prefix you receive from npm after installation of a new package is called a caret. With its maximum patch version, it provides you with the most recent minor version that is currently accessible.
2) Tilde or "~"
A tilde prefix only promotes patch versions, so you'll always get the most recent patch for your current minor.
3) comparison operator
The comparison operators >,, =, >=, and = are used to indicate a range of stable versions:
You can also indicate a range by using the hyphen (-):
The hyphen is surrounded by spaces on both sides.
4) prerelease version
Use the npm tag to specify a prerelease version, such as alpha and beta:
You can use the comparison like > and a prerelease tag to identify a range of prerelease versions:
5) Include multiple sets of versions
Include multiple sets of the npm versions using the "||" operator.
6) Use the x symbol
Use the x symbol after the version to show any version in Npm. For example, 1.x shows all versions with the major version 1, such as 1.0.0, 1.0.2, 1.8.2, 1.9.20, etc.
In the lock file
The lockfile's name and structure will allow you to recognize it. It will be called a package-lock. Imagine a bug that only manifests itself when you execute the code and doesn't reproduce for any of your colleague devs. This is what it would be like to not share dependencies with your coworkers when working as a team. When you use several versions of your dependencies, this can occur.
Save the day with Lock File!
If you have a lock file, npm verifies all versions of the lock file before installing your dependencies. Assume the new developer would have the exact same version if he shared the same lock file with the original developer.
If you want to maintain consistency among all the team members involved with the same project, the lock file must be uploaded to git.
You must use the "npm update" command to update your dependencies to their maximum version (in the range supplied). All developers on the team will have access to the same updated dependencies because this command respects semantic versioning and updates the lock file with the newly installed version.
Dependency pinning is yet more approach to the inconsistent problem. By simply deleting any carets, tildes, or other prefix symbols, means specifying a very precise version rather than a variety of versions. Example: If you write 1.2.3 once, it will always be 1.2.3. The developers will always have the same version thanks to this method.
The nodejs semantic versioning uses to operate the required version with a new function.