Linux command
ncu 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Check for updates
ncu
Update package.json
ncu -u
Check specific packages
ncu [lodash] [react]
Check packages matching pattern
ncu "/^@types/"
Exclude packages
ncu --reject [typescript]
Interactive mode
ncu -i
Check only minor updates
ncu --target minor
Show peer dependencies
ncu --peer
说明
ncu (npm-check-updates) identifies outdated dependencies in package.json. It shows available updates without installing them. The tool compares installed versions against npm registry. Output shows current version, wanted version, and latest version for each package. Update mode (-u) modifies package.json with new versions. Run npm install afterward to actually install updates. Interactive mode lets you select which packages to update. This is useful when upgrading incrementally or avoiding certain updates. Target levels control update scope: patch allows only patch updates (1.0.x), minor allows minor (1.x.x), and latest allows any version. Filter and reject patterns focus on specific packages. Regex patterns match package names.
参数
- -u, --upgrade
- Update package.json.
- -i, --interactive
- Interactive mode.
- -t, --target _LEVEL_
- Update target (latest, minor, patch, semver).
- -f, --filter _PATTERN_
- Only include matching packages.
- -x, --reject _PATTERN_
- Exclude matching packages.
- -g, --global
- Check global packages.
- -p, --packageManager _PM_
- Package manager (npm, yarn, pnpm).
- --peer
- Check peer dependencies.
- -d, --deep
- Check workspaces.
- --pre
- Include prerelease versions.
- --format _FMT_
- Output format.
- --doctor
- Test upgrades one by one.
FAQ
What is the ncu command used for?
ncu (npm-check-updates) identifies outdated dependencies in package.json. It shows available updates without installing them. The tool compares installed versions against npm registry. Output shows current version, wanted version, and latest version for each package. Update mode (-u) modifies package.json with new versions. Run npm install afterward to actually install updates. Interactive mode lets you select which packages to update. This is useful when upgrading incrementally or avoiding certain updates. Target levels control update scope: patch allows only patch updates (1.0.x), minor allows minor (1.x.x), and latest allows any version. Filter and reject patterns focus on specific packages. Regex patterns match package names.
How do I run a basic ncu example?
Run `ncu` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -u, --upgrade do in ncu?
Update package.json.