I recommend a tool that can help us quickly upgrade project dependencies, which is Taze written by the great AntFu.
Taze only requires a single command to detect upgradable dependencies in the project. Let's see how to use it.
Installation#
npm i -g taze
# Or you can directly use npx taze
Usage/Scan for Upgradable Dependencies#
If you have installed it globally, just type Taze.
You can see a very detailed output including version changes and the latest release dates.
The commands above only scan and do not actually upgrade dependencies.
Usage/Execute Upgrade Operation#
If you want to execute the upgrade operation, just append -w to the command.
taze -w # Taze will directly write all upgradable dependencies into package.json
Next, you can complete the upgrade.
Tip:
ni is also a small tool written by AntFu, you can check it out here
ni is equivalent to npm install or yarn install.
Additionally, Taze supports monorepo; just append -r to the command, and all subdirectories containing package.json will be scanned.
taze -r # Scan all subdirectories
If I want to update all dependencies of this project, including those in subdirectories, I just need to do this:
taze -r -w
Usage/Other Features#
taze -p # Match only dependencies
taze -d # Match only devDependencies
taze -w -i # Write to package.json and then install directly, will prompt to choose installation source
taze -h # Help, view all commands
Also, Taze supports configuration files. Create a taze.config.js file in the project directory.
import { defineConfig } from 'taze'
export default defineConfig({
// Ignored package names
exclude: [
'webpack'
],
// Whether to fetch the latest package information from the registry, not using cache
force: true,
// Whether to write to package.json
write: true,
// Whether to execute installation directly after upgrade
install: true,
// Set different upgrade modes for each package
packageMode: {
'typescript': 'major',
'unocss': 'ignore',
'/vue/': 'latest'
},
// Disable checking the "overrides" field in package.json
depFields: {
overrides: false
}
})
For more usage methods, you can check the documentation of Taze.
[This article is not to be reproduced, thank you]