在现有项目中更新 Angular CLI [英] Update Angular CLI in existing project
问题描述
我正在现有项目中开发 angular-cli 1.0.4,我想将版本更新到 1.2.4.使用 npm 卸载旧的并更新到新的并影响我现有项目的最佳方法是什么?更新 package.json 文件的版本.
I'm working on angular-cli 1.0.4 in existing project, I would like to update the version to 1.2.4. What is the best way to uninstall the old one and update to the newer one using npm with effecting my existing project? which updates the version on package.json file.
推荐答案
将你的角度cli
更新到any
版本的指南
2018 年 10 月 23 日更新参考:如何在 ng cli 和 angular 更改版本最佳实践时更新应用:
如果您使用的是 Angular CLI 版本 6+,只需运行 ng update
然后按照命令行指令.另请查看本指南 更新您的角度项目
If you are on Angular CLI version 6+ just run
ng update
then follow the command line instructions. Also checkout this guide Updating your Angular projects
<小时>
最近我正在将我的项目从 1.0.4
升级到 1.3.0-beta
,但同样适用于任何 angular cli 版本.
Recently I've being upgrading my project from 1.0.4
to 1.3.0-beta
, but the same will apply in case of any angular cli versions.
所以首先只安装你想要将项目升级为 https 的 angular cli://github.com/angular/angular-cli#updating-angular-cli 说:
So first just install angular cli you want to upgrade your project to as https://github.com/angular/angular-cli#updating-angular-cli is saying:
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@<put exact version here>
升级步骤:
- 创建一个
new blank
项目,例如ng new project-name
您可以命名您的新playground"项目
与您的旧项目
完全一样,但请确保它与您当前的项目位于不同的文件夹中. 将您的
app
文件夹从您的old project
复制/替换为您刚刚创建的new project
- Create a
new blank
project likeng new project-name
you can name yournew "playground" project
exactly like yourold project
, but make sure that it sits in the different folder from your current one. Copy/replace your
app
folder form yourold project
tonew project
you just created
对项目中的所有其余文件进行所有自定义更改:
3a.将旧项目中所有与项目相关的 npm 包放入 package.json
(使用比较工具)新旧 package.json
将只是 @angular/cli@version
及其相关包版本,如 karma
等
3b.使用比较工具(请参阅下面的更新)确保您从所有与 cli 相关的文件(如 .angular-cli.json<)中携带所有自定义内容
、.gitignore
、index.html
、src/polyfills.ts
、src/main.ts
、src/test.ts
等
Bring all custom changes to all the rest files in a project:
3a. Put all your project related npm packages from your old project in to package.json
(use compare tool) the difference between your old and new package.json
is gonna be just @anngular/cli@version
and its related packages versions like karma
, etc
3b. Using compare tool(see UPDATE below for that matter) make sure that you bring all your custom stuff form all cli related files like .angular-cli.json
, .gitignore
, index.html
, src/polyfills.ts
, src/main.ts
, src/test.ts
, etc
运行 npm install
或 yarn
完成上述所有操作后,您可以删除或存档 旧项目
以防万一,并从那时起继续使用 新项目
.
Once you done with all above you can remove or archive the old project
just in case and keep going with a new project
from that point.
更新:你也可以使用这个 angular-cli-diff 找出版本之间的区别,例如 https://github.com/cexbrayat/angular-cli-diff/compare/1.4.0...1.5.0(参见文件更改
标签)
UPDATE: you also can use this angular-cli-diff to find out what is the difference between the versions e.g https://github.com/cexbrayat/angular-cli-diff/compare/1.4.0...1.5.0 (see the
Files changed
tab)
所以使用 angular-cli-diff 你可以:
- 区分 cli 版本,例如:https://github.com/cexbrayat/angular-cli-diff/compare/1.4.0...1.5.0
- 点击
文件更改
标签 - 将更改应用于您当前的项目.
npm install/yarn
- 测试上述步骤
5(a-e)
中的更改
- diff the cli versions e.g: https://github.com/cexbrayat/angular-cli-diff/compare/1.4.0...1.5.0
- click on
File changed
tab - Apply the changes to your current project.
npm install / yarn
- Test the changes in step
5(a-e)
as above
这篇关于在现有项目中更新 Angular CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!