How To Update All Package In Package.json

Introduction
 
A few days ago, I wanted to add a few new functionalities in my existing project but when I executed the project, there arrived so many errors and I got an idea that it was all about package versioning issues.
 
So, I thought to update all my packages at once and quick start my pending tasks. I found a few ways to update all the packages listed in the package.json file.
 
Updating any npm package is a very straightforward task, and you can do it by just writing a few commands, so in this post, I am going to share the way you can use it to update all the packages in package.json file into our Angular application. 
 
How to check outdated packages in our project
 
Sometimes we want to know about how many packages in our project are outdated and needs to be updated with latest version, the solution is to use the below npm command.
  1. npm outdated  
And you will get complete details about all the outdated packages with their versions and also the latest versions:
 
 
Ways to update npm packages 
 
For updating any package there are two ways :
  • Using npm update
  • Using npm-check-update package 
Using npm update 
 
Using this option is pretty straight-forward , you just need to write the command and all the packages will be updated within a minute based on your number of packages and internet speed, just write command and your package will be updated.  
  1. npm update  
After executing the above command, all the packages that need to be updated will be handled by update command and you can see the list of updated packages:
 
 
Update using npm-update-ckeck package 
 
This is a package available at npmjs.org , named npm-update-check, which works the same as npm update command. 
 
But the difference is that it's a utility that automatically adjusts packages which are listed into package.json file , whenever any updates are required. For that we need to install it via command: 
  1. npm install -g npm-check-updates  
After installing the above package to a global location, now we will be able to update packages automatically. The next step is to update all the packages by running the command:
  1. ncu -u // tells to update via npm package  
And then install it via npm install.
 
Conclusion
 
So this is how you can update your packages within a short period of time. I hope it will help you some day. Thanks for reading.