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