ng update
更新你的應用及其依賴。參見 https://update.angular.io/
Updates your application and its dependencies. See https://update.angular.io/
ng update [options]
說明
透過執行以下命令,對核心框架和 CLI 的當前穩定版本執行基本更新。
Perform a basic update to the current stable release of the core framework and CLI by running the following command.
ng update @angular/cli @angular/core
要更新到下一個 Beta 或預發行版本,請使用 --next
選項。
To update to the next beta or pre-release version, use the --next
option.
要從一個主要版本更新到另一個,請使用以下格式
To update from one major version to another, use the format
ng update @angular/cli@^<major_version> @angular/core@^<major_version>
我們建議你始終更新到最新的補丁版本,因為它包含我們自最初的主版本以來發布的修復程式。例如,使用以下命令獲取最新的 10.xx 版本並使用該版本進行更新。
We recommend that you always update to the latest patch version, as it contains fixes we released since the initial major release. For example, use the following command to take the latest 10.x.x version and use that to update.
ng update @angular/cli@^10 @angular/core@^10
有關更新應用程式的詳細資訊和指南,請參見互動式的 Angular 升級指南 。
For detailed information and guidance on updating your application, see the interactive Angular Update Guide.
選項
選項 | 說明 | Value Type | Default Value |
---|---|---|---|
--all | Deprecated 是否更新 package.json 中的所有套件。 Whether to update all packages in package.json. | boolean | false |
--allow-dirty | 是否允許本儲存庫包含已修改或未追蹤的檔案時進行更新。 Whether to allow updating when the repository contains modified or untracked files. | boolean | |
--create-commits | 為升級和遷移的過程,在原始碼控制中建立一些提交。 Create source control commits for updates and migrations. 別名: -C | boolean | false |
--force | 如果為 false,那麼如果已安裝的包與這次更新不相容,就會報錯並退出。 If false, will error out if installed packages are incompatible with the update. | boolean | false |
--from | 要從哪個版本開始遷移。只能用在升級單個套件時,而且只能用於遷移工作。 Version from which to migrate from. Only available with a single package being updated, and only on migration only. | string | |
--help | 在控制檯顯示關於本命令的幫助資訊。 Shows a help message for this command in the console. | true|false|json|JSON | false |
--migrate-only | 只執行遷移,而不更新已安裝的版本。 Only perform a migration, do not update the installed version. | boolean | |
--next | 使用與發佈版本,包括 beta 和 RC。 Use the prerelease version, including beta and RCs. | boolean | false |
--packages | 要更新的套件名稱(可以有多個)。 The names of package(s) to update. | array | |
--to | 要遷移到哪個版本。只能用在升級單個套件時,而且只能用於遷移工作。需要指定過 from 引數。預設是所檢測到的已安裝版本。 Version up to which to apply migrations. Only available with a single package being updated, and only on migrations only. Requires from to be specified. Default to the installed version detected. | string | |
--verbose | 在執行期間顯示關於內部操作的詳情。 Display additional details about internal operations during execution. | boolean | false |