DEV Community

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

Posted on • Edited on

20 1 1 1 1

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
prateekwayne profile image
Prateek Wayne

Thanks for this
Helped me a lot

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay