How to upgrade all packages in JS or NodeJS?
Though one should always read the change-logs of the newly released package and then migrate to the newer version, but still knowing the commands to identify the outdated packages is important.
How to find all the outdated packages in your global space?
npm outdated -g --depth=0
This would find all the outdated npm packages installed in your system in the global space, also it gives you the newer version on which you can upgrade.
How to find all the outdated packages in your local space?
PS- Make sure to run this command in the directory where the code resides.
How to update all globally outdated packages?
npm update -g
This would update all the globally outdated packages to the latest versions which were recommended by the previous command.
How to update a single package globally?
npm update -g <package-name>@<version>
How to update all packages in a local repository?
Go to the project directory and then run the following command
The above steps are helpful for when we use NPM. But when you use YARN then the steps to upgrade to the latest package are much simpler. Just use the following command.
yarn upgrade-interactive --latest
You would be prompted for upgrading all the packages as per the latest versions available.
PS- Please note, yarn only works when you have
yarn.lock file, which is generated when you use yarn in your project.