本文介绍了如何在 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迁移到较新版本时的重大更改检查此答案
- 运行
npm uninstall -g angular-cli
然后npm cache clean
- 运行
npm install -g angular-cli
更多详情这里 - 备份您的
应用
- 转到您的
app
文件夹 - 运行
ng init
- 此命令将通过将一些文件写入现有应用程序来初始化angular-cli
应用程序.小心覆盖现有文件,跳过您不确定的文件,但您始终可以参考您的备份. - 运行
ng new simple-app
- 你将使用这个作为angular-cli
真实应用的来源. - 将
angular-cli
在您的app
中生成/需要的文件与simple-app
进行比较,以查看在步骤 4. - 确保所有需要的
angular-cli
npm 模块都安装到您的app
(比较package.json
文件) - 运行
npm start
它可能会给你一个你必须修复的错误.您可能需要返回此处的步骤 7. 和 8..如果您弄乱了软件包,您可能需要删除node_modules
文件夹并运行npm install
. - 您可以在 http://localhost:4200 访问您的
应用
>- Run
npm uninstall -g angular-cli
thennpm cache clean
- Run
npm install -g angular-cli
more details here - Backup your
app
- Go to your
app
folder - Run
ng init
- this command will initialize theangular-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. - Run
ng new simple-app
- this one you will be using as aangular-cli
source of truth app. - Compare files produced/required by
angular-cli
in yourapp
withsimple-app
to see if anything gets missed during step 4. - Make sure that all requited
angular-cli
npm modules gets installed in to yourapp
(comparepackage.json
files) - 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 removenode_modules
folder and runnpm install
. - You can access your
app
at http://localhost:4200
这篇关于如何在 Angular CLI 上迁移 Angular-2 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!