TIL: NPM | Automatically update package.json dependencies

imomaliev

Sardorbek Imomaliev

Posted on September 20, 2021

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

💖 💪 🙅 🚩
imomaliev
Sardorbek Imomaliev

Posted on September 20, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related