How to update each dependency in package.json to the latest version
You have 2 options:
I use this when starting work on a project that’s been sitting for a while and all the dependencies are outdated. The npm-check-updates tool rewrites your package.json version ranges to the latest available versions, then npm install pulls them down.
Be careful with major version bumps — they can include breaking changes. It’s a good idea to run your test suite after updating. If something breaks, you can check the diff in package.json to see which package jumped a major version and pin it back.
Option 1 – Recommended (Using npx)
npx npm-check-updates -u
npm install
Option 2 – Older way (Using npm globally)
There’s a longer note on JavaScript over here.
npm i -g npm-check-updates
ncu -u
npm install