TIL: NPM | Automatically update package.json dependencies
Sardorbek Imomaliev
Posted on September 20, 2021
Story
During chore update of my vue-ts template dependencies (to learn more about it, read here) I was doing usual npm "upgrade" steps.
- 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). - 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.
npm -g install npm-check-updates
-
ncu
to see outdated versions orncu --upgrade
to update thepackage.json
.
Links
💖 💪 🙅 🚩
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.