本文介绍了如何在 Angular CLI 上迁移 Angular-2 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用 Sing App - Web &用于我们任务的 Angular 2.0 仪表板模板,但此应用程序不是基于 Angular CLI 项目.我必须在 Angular CLI 上使用这个应用程序.我尝试了一些选项但没有成功.请建议将这个应用程序带到 Angular CLI 的最佳方式.

I am going to use Sing App - Web & Angular 2.0 Dashboard template for our assignment but this app is not based on Angular CLI project. I have to bring this app on Angular CLI.I have tried some option but not succeeds. Please suggest the best way bring this app over Angular CLI.

推荐答案

UPDATE 08/07/2017: 如果您正在寻找如何升级 angular cli迁移到较新版本时的重大更改检查此答案

  1. 运行 npm uninstall -g angular-cli 然后npm cache clean
  2. 运行 npm install -g angular-cli 更多详情这里
  3. 备份您的应用
  4. 转到您的 app 文件夹
  5. 运行 ng init - 此命令将通过将一些文件写入现有应用程序来初始化 angular-cli 应用程序.小心覆盖现有文件,跳过您不确定的文件,但您始终可以参考您的备份.
  6. 运行 ng new simple-app - 你将使用这个作为 angular-cli 真实应用的来源.
  7. angular-cli 在您的 app 中生成/需要的文件与 simple-app 进行比较,以查看在步骤 4.
  8. 确保所有需要的 angular-cli npm 模块都安装到您的 app(比较 package.json 文件)
  9. 运行 npm start 它可能会给你一个你必须修复的错误.您可能需要返回此处的步骤 7.8..如果您弄乱了软件包,您可能需要删除 node_modules 文件夹并运行 npm install.
  10. 您可以在 http://localhost:4200
  11. 访问您的应用>
  1. Run npm uninstall -g angular-cli thennpm cache clean
  2. Run npm install -g angular-cli more details here
  3. Backup your app
  4. Go to your app folder
  5. Run ng init - this command will initialize the angular-cli app by writing some files in to your existing app. Be careful with overriding the existing files, skip the ones you are not sure, however you always can refer to your backup.
  6. Run ng new simple-app - this one you will be using as a angular-cli source of truth app.
  7. Compare files produced/required by angular-cli in your app with simple-app to see if anything gets missed during step 4.
  8. Make sure that all requited angular-cli npm modules gets installed in to your app (compare package.json files)
  9. Run npm start it might give you an errors you have to fix. You might need to go back to steps 7. and 8. here. If you mess up the packages you might need to remove node_modules folder and run npm install.
  10. You can access your app at http://localhost:4200

这篇关于如何在 Angular CLI 上迁移 Angular-2 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 10:58
查看更多