← 返回命令列表

Linux command

ng-update 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List

ng update

Update Angular core and CLI

ng update @angular/core @angular/cli

Update a specific package

ng update [package-name]

Update to next/prerelease

ng update @angular/core --next

Force update

ng update @angular/core --force

Run migrations only

ng update @angular/core --migrate-only --from=[15] --to=[16]

Create git commits

ng update @angular/core @angular/cli --create-commits

说明

ng update updates Angular packages and dependencies to a newer version and runs schematics that migrate application code for breaking changes. It is part of the Angular CLI. Running ng update without arguments prints a list of installed packages that have newer versions available, along with the suggested update command. With one or more package names, it performs the update and executes any associated migration schematics. The command refuses to run by default if the repository has uncommitted changes; pass --allow-dirty to override, or commit/stash first.

参数

--allow-dirty
Permit updates when the working tree has modified or untracked files (default: false).
-C, --create-commits
Create source-control commits for each update and migration step (default: false).
--force
Bypass peer dependency version mismatches (default: false).
--from _version_
Version to migrate from. Only valid with a single package and --migrate-only.
--to _version_
Target version for migrations. Requires --from and --migrate-only; defaults to the detected installed version.
--migrate-only
Run migration schematics only, without changing installed versions.
--name _name_
Specify a particular migration to run. Only valid for a single package update.
--next
Use prerelease versions (beta / release candidate) when resolving the target version.
--verbose
Show additional execution details.
--help
Print help.

FAQ

What is the ng-update command used for?

ng update updates Angular packages and dependencies to a newer version and runs schematics that migrate application code for breaking changes. It is part of the Angular CLI. Running ng update without arguments prints a list of installed packages that have newer versions available, along with the suggested update command. With one or more package names, it performs the update and executes any associated migration schematics. The command refuses to run by default if the repository has uncommitted changes; pass --allow-dirty to override, or commit/stash first.

How do I run a basic ng-update example?

Run `ng update` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --allow-dirty do in ng-update?

Permit updates when the working tree has modified or untracked files (default: false).