The first step in updating dependencies involves opening the package.json file. Understanding the two categories of dependencies – direct and indirect, is key.
We need to update both categories of dependencies.
// To update the dependencies, we will use the 'npm update' command. npm update
This command updates all packages in the package.json file using the latest specified range in the package distribution tags.
Understanding Semver and NPM Versioning
Before moving forward, we need to understand Semver or Semantic Versioning, a versioning scheme for software that aims to convey meaning about the underlying changes. Each version has three parts: major, minor, and patch.
// Version structure MAJOR.MINOR.PATCH
When updating our dependencies in the package.json file, we may use three symbols to define the updates’ scope.
Upgrading Major Versions of Packages
If a new major version has been released which is not covered by the version range specified in your package.json file, then we need to update the version manually.
// To install a specific version of a package npm install packageName@versionNumber
Finally, remember to test all functionalities of your application before integrating the updated packages into your work because some updates may include major changes or some features of the older version might be deprecated in the new one.