Node

TIL: How to update all package.json dependencies at once

1 minute read Published:

Short howto: update all npm dependencies using jq and xargs

Dependencies

  • node.js and npm (obviously)
  • jq
  • xargs (may needs to be installed manually)

Update all dependencies to their latest version:

cat package.json | \
	jq -r '.dependencies | keys[]' | \
	xargs -I {} npm i -S {}@latest

Update all devDependencies to their latest version:

cat package.json | \
	jq -r '.devDependencies | keys[]' | \
	xargs -I {} npm i -S {}@latest

Alias the commands for easier reuse

To reuse the commands without having to remember them just put them into your .bashrc or .bash_profile file. Add this to the end of your bash configuration and restart your shell afterwards: