rahulrao0209
Posted on October 30, 2022
NPM package versions
NPM packages have a version number which looks like 0.0.0 for example.
- The first digit specifies the major version.
- The second digit specifies the minor version.
- The third digit specifies the patch version.
A major version update may not be backward compatible and can have breaking changes that may break your codebase if its using the previous major version.
A minor version update is backward compatible and generally consists of additional functionalities or features.
A patch version is a bugfix version and is backward compatible.
Updating NPM packages
NPM packages can be updated using the
npm update
command.
To update a specific package, use for example -
npm update packagename
To update a package to a specific version, use for example -
npm update packagename@1.0.2
To update all packages in the codebase use - npm update
^ is used to specify that we should only accept minor and patch version updates.
packagename: ^1.0.0
~ is used to specify that we should only accept patch version updates.
packagename: ~1.0.0
*
is used to specify that we should accept all version updates.
packagename: *1.0.0
Note - Using *
and accepting all version updates is not recommended and can cause breaking changes.
Also, without specifying any of the ^ ~ or *
symbols, the packages will not get updated to newer versions.
Posted on October 30, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.