To update all packages and package.json to the latest stable version. Install npm-check-updates package
npm i -g npm-check-updates
Then to update package.json with all the latest version numbers
ncu -u
Then to install updated packages from updated package.json
npm install
If in a rails project
yarn install && yarn upgrade --latest
To update all gems and node packages. Be very careful
bundle update --all && ncu -u && yarn install && yarn upgrade --latest