且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Angular CLI上迁移Angular-2应用

更新时间:2023-09-30 10:36:04

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

  1. 先运行npm uninstall -g angular-cli,然后再运行npm cache clean
  2. 运行npm install -g angular-cli更多详细信息此处
  3. 备份您的app
  4. 转到您的app文件夹
  5. 运行ng init-此命令将通过向现有应用程序写入一些文件来初始化angular-cli应用程序.覆盖现有文件时要小心,跳过不确定的文件,但是始终可以参考备份.
  6. 运行ng new simple-app-您将以此为真理应用程序的angular-cli源.
  7. app中的angular-cli生成/需要的文件与simple-app进行比较,以查看在步骤 4期间是否丢失了任何内容.
  8. 确保所有返回的angular-cli npm模块都已安装到您的app中(比较package.json文件)
  9. 运行npm start,它可能会给您一个必须修复的错误.您可能需要在此处返回步骤 7. 8..如果您弄乱了软件包,则可能需要删除node_modules文件夹并运行npm install.
  10. 您可以通过 http://localhost:4200
  11. 访问您的app
  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