. Advertisement .
. Advertisement .
If you want to update all dependencies in package.json to the latest version but don’t know the way, then read this article to get yourself the answer to “how to update all dependencies in package.json to the latest version”.
How to update all dependencies in package.json to the latest version?
Dependencies are considered one of the crucial concepts of pub package management. Your package will need a dependency package to work. You only need to list out the immediate dependencies ( the software that is used directly by the package ) and the dependencies already defined in your pubspec
Method 1: Utilize npm-check-updates
This is the first way to upgrade all dependencies to the latest version; you can try running this command:
npm install -g npm-check-updates
Then you run the below command to examine which package the update is available in:
[====================] 5/5 100%
express 4.12.x → 4.13.x
multer ^0.1.8 → ^1.0.1
react-bootstrap ^0.22.6 → ^0.24.0
react-a11y ^0.1.1 → ^0.2.6
webpack ~1.9.10 → ~1.10.5
Once you have determined which packages are available to update, you can now run the below command:
New dependencies will be shown in the current directory meanwhile list global packages with new releases by this command:
Next, run the following command:
Then you just need to run this command:
Now all dependencies are updated to the latest version.
Method 2: Run the below command if you use npx
Here’s how to update all dependencies in package.json to the latest version if you use NPX
Run the below command if you use npx:
And same as on, you run command npx npm-check-updates-u to check available packages
npx npm-check-updates -u
All your dependencies can be updated at once just by running this command:
Method 3: Run the following program
# Install and use the `npm-check-updates` package.
$ npm install -g npm-check-updates
# If you agree, update package.json.
$ npm-check-updates -u
#then delete node_modules folder
rm -rf node_modules
#now you can update all package to latest version
Method 4: Upgrade single package
Run this command to get a single package updated to the latest version
npm install yourPackage@latest
And run this command if you intend to update the prismjs version.
npm install prismjs@latest
The package will be in your devDependencies if you use the command with -save-dev
npm install prismjs@latest --save-dev
With this method, all your dependencies can be upgraded to the latest version too.
Method 5: Utilize npm-upgrade
There has no difference with the npm-check-updates package, the npm-upgrade package can also help you upgrade all dependencies to the latest version by running this command
npm i npm-upgrade
Next is the npm-upgrade command:
That command will examine and force you to update each package. You will transfer no or yes, like this
Update "@angular/common" in package.json from 2.4.8 to 2.4.10? (Use arrow keys)
Above are all the methods that you can try to update all dependencies. Good luck!
We hope you have got a method to solve the problem of “how to update all dependencies to the latest version”. Please leave your comments and questions in the comments section below to let us know. Thank you for reading the article.