DEV Community 👩‍💻👨‍💻

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

Posted on • Updated 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 (0)

Hacktoberfest is happening now!



It is a month-long celebration of open source. For a lot of devs, its their introduction to open source.


Check out the Hacktoberfest tag on DEV to keep up with the latest!