Frequently Asked Questions (FAQs)
Where is my package.json file?
If you have a monorepo pattern (multiple projects in the same repository) you might have multiple package.json files that all need to be updated independently
What format is my package.json file?
Your package.json file is json as expected, but also has several required and several recommended fields.
Required fields: name, version.
Recommended fields: dependencies, scripts, author, private, license.
For more information see https://flaviocopes.com/package-json
What is Semantic Versioning?
Semantic Versioning, or semver, is a versioning strategy for npm packages.
It is not just a version, but also a contract between the package creators and users where changes of different types (breaking, major, minor, patch) are defined as a numerical value.
When you use a package or publish an npm package, you should use semver, which is defined by an optional range specifier, and three numbers eg RANGEx.y.z / ~1.0.1
X=breaking/major - update when the package update will breaking existing usages.
Y=feature/minor - update when a significant feature is released
Z=patch/fix - update when a bug is fixed, or an inconsequential change is made for the end users
To avoid constantly updating your package.json file, you can use a range which mentions that newer versions of the package are automatically accepted if they meet the range specifier
~/tilde: Flexible patch - Will automatically use new patch versions eg ~1.0.0 will automatically use versions up to but excluding 1.1.0 eg 1.0.1, 1.0.2 etc
^/caret: Flexible minor - Will automatically use new minor versions eg ^1.0.0 will automatically use versions up to but excluding 2.0.0 eg 1.1.0, 1.6.6 etc
>=/greater than equals: Flexible major - Will automatically use any version over a specific version eg >=1.0.0 will match anything over 1.0.0
Benefits over npm-check-updates:
- Disregards existing semver ranges but resets to a baseline, which is useful for older projects / those where the newest version is unknown and may be a major bump.
- Allows selective rollback of updated packages
- Allows resetting of all semver range specifiers to a consistent range specifier
- Semver is unreliable, the "next" version of a package may or may not be ahead of "latest". This tool has a "newest" option that uses the highest/newest semver version from the "next" and "latest" versions