If you have jq, a lightweight and flexible command-line JSON processor, installed in your computer, it's easy to manipulate the command to update dependencies to the latest version at once.
Update dependencies
Check:
cat package.json | jq -r '.dependencies | keys | join("\\n")'
Perform installing:
cat package.json | jq -r '.dependencies | keys | map(. + "@latest") | join(" ")' | xargs npm i
Update devDependencies
cat package.json | jq -r '.devDependencies | keys | map(. + "@latest") | join(" ")' | xargs npm i
Top comments (2)
How about
npm update
andnpm update --dev
? (ref)Because it does not always update packages to the latest versions if those are caret/tilde dependencies:
docs.npmjs.com/cli-commands/update...
It means that
npm update
tries to update while keep satisfying app's package dependencies.