DEV Community

Cover image for TIL: NPM | Automatically update package.json dependencies
Sardorbek Imomaliev
Sardorbek Imomaliev

Posted on • Edited on

TIL: NPM | Automatically update package.json dependencies

Story

During chore update of my vue-ts template dependencies (to learn more about it, read here) I was doing usual npm "upgrade" steps.

  1. Run npm update to automatically update my packages to the latest versions From docs: > This command will update all the packages listed to the latest version (specified by the tag config), respecting the semver constraints of both your package and its dependencies (if they also require the same package).
  2. Run npm outdated - to see what could be still updated.

npm update - only updates package-lock.json and does not change package.json. I started searching for a way to automatically update my dependencies in package.json file as well.

Question

How to automatically update package.json dependencies' versions?

Answer

Quick searching pointed me to this stackoverflow post, where one of the answers suggested using npm-check-updates tool.

  1. npm -g install npm-check-updates
  2. ncu to see outdated versions or ncu --upgrade to update the package.json.

Links

Top comments (1)

Collapse
 
prateekwayne profile image
Prateek Wayne

Thanks for this
Helped me a lot