在现有项目中更新Angular CLI [英] Update Angular CLI in existing project

查看:221
本文介绍了在现有项目中更新Angular CLI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在现有项目中处理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版本的指南

更新2018年10月23日参考:

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>

升级步骤:

  1. 创建一个new blank项目,例如ng new project-name ,您可以将new "playground" project命名为与old project完全相同的名称,但是请确保它与当前文件夹位于不同的文件夹中.
  2. app文件夹从old project文件夹复制/替换为刚创建的new project

  1. Create a new blank project like ng new project-name you can name your new "playground" project exactly like your old project, but make sure that it sits in the different folder from your current one.
  2. Copy/replace your app folder form your old project to new project you just created

将所有自定义更改带到项目中的所有其余文件:
3a.将您旧项目中所有与项目相关的npm软件包放入package.json(使用比较工具) 新旧package.json之间的区别就是@anngular/cli@version及其相关软件包的版本,例如karma
3b.使用比较工具( 有关此问题,请参见下面的更新 ),确保您将所有自定义内容从所有与cli相关的文件(如.angular-cli.json.gitignoresrc/polyfills.tssrc/main.tssrc/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 installyarn

完成以上所有操作后,就可以删除或存档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 即可:

  1. 比较cli版本,例如: https ://github.com/cexbrayat/angular-cli-diff/compare/1.4.0...1.5.0
  2. 点击File changed标签
  3. 将更改应用于当前项目.
  4. npm install / yarn
  5. 如上所述测试步骤5(a-e)中的更改
  1. diff the cli versions e.g: https://github.com/cexbrayat/angular-cli-diff/compare/1.4.0...1.5.0
  2. click on File changed tab
  3. Apply the changes to your current project.
  4. npm install / yarn
  5. Test the changes in step 5(a-e) as above

这篇关于在现有项目中更新Angular CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆