Is there a shortcut for updating all package dependencies that are of a particular scope.
For example is there are in the following package.json
is there a quick way to update only those packages with an @example
scope?:
…
dependencies: {
alpha,
bravo,
@example/a,
@example/b,
@example/c,
@example/d,
@example/e,
@example/f,
}
If you still want to update everything to the latest version, you can use the tool npm-update-all . It's as easy as running this command in your project folder. As you can see, npm-update-all will update all your packages to the latest version.
I wrote small tool for that. Run npx update-by-scope @example
for Yarn project and npx update-by-scope @example npm install
for Npm project
Using yarn:
yarn upgrade --scope @example
I update dependencies using the npm-check-updates
package -- just install it globally then run ncu
. By default it runs in "check" mode against all packages, but you can pass a command-line flag to have it write the newest version of each package to package.json
. It supports filtering so you could apply the updates only to a single scope, like ncu '/@angular\/.*/'
.
I have the same problem in angular
project.
I use from the script
section in package.json
.
I set the custom name
(e.g update-scope
) as key
, and set command(s) as value
. follow this:
"scripts": {
"ng": "ng",
"build": "node package-builder",
"update-scope": "npm update @example/a && npm update @example/b && ..."
}
then run custom name
with this command:
npm run update-scope // `update-scope` is my custom name
finally, all of my packages
in my scope
was updated.
I hope is useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With