Say you have “the-package” installed at version 3.x and want to upgrade to 5.x
You would do this:
npm install the-package@5
it will update package.json and package-lock.json as well.
You can also update multiple packages in one command like npm install package1@5 package2@16
To check which packages need updates, run npm outdated