在现有项目中更新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.
推荐答案
将your angular cli
更新为any
版本的指南
The guide to update your angular cli
to any
version
UPDATE 23-Oct-2018 ref: how to update an app when ng cli and angular change version best practice:
如果您使用的是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
,但是在任何角度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.
因此,首先只需安装angular cli,您想将项目升级为 https ://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
,您可以将new "playground" project
命名为与old project
完全相同的名称,但是请确保它与当前文件夹位于不同的文件夹中. -
将
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
之间的区别就是@anngular/cli@version
及其相关软件包的版本,例如karma
等
3b.使用比较工具( 有关此问题,请参见下面的更新 ),确保您将所有自定义内容从所有与cli相关的文件(如.angular-cli.json
,.gitignore
,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
完成以上所有操作后,就可以删除或存档old project
,以防万一,并继续使用new project
.
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 (请参见
Files changed
标签)
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
- 点击
File changed
标签 - 将更改应用于当前项目.
-
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屋!