Skip to content

Instantly share code, notes, and snippets.

@Ronin1702
Last active September 26, 2023 12:12
Show Gist options
  • Select an option

  • Save Ronin1702/190913cfce276e1491512cab7c208d12 to your computer and use it in GitHub Desktop.

Select an option

Save Ronin1702/190913cfce276e1491512cab7c208d12 to your computer and use it in GitHub Desktop.
Update All dependencies in `package.json` at once

Update all dependencies in package.json at once

Install npm-check-update package.

-g is a globale tag, I recommend install this globally, and if you don't want to use this package gloabbly, take this tag off

npm i -g npm-check-update

Get update list and install

This wil only update the dependencies install in your current package.json path. If you need to update others such as client or server side package.json you will need to go to the path of that folder to execute.

ncu -u && npm i

You can separate the command above if you would like to get the update list before install them again.

package.json script method:

Uh I see, you want it to be more convenient and you have come this far to get the easy setup that will take care of it all. GRANTED!

-Add the script below to your package.json after you have installed npm-check-update package to your global or local directory.

"scripts":{
"update": "cd client && ncu -u && npm i && cd .. && cd server && ncu -u && npm i &&ncu -u && npm i"
},
  • Now, simply npm run update and sit back, relax, let the freshness flow through you dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment