本文介绍了将Angular 4.x迁移到Angular 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读以下博客和文档

I have read the following blogs and documentation

  • Angular Blog
  • Alligator IO Docs
  • Official Documentation

,也没有关于如何从4.x迁移到5的明确信息.

and no clear information about how to migrate from 4.x to 5.

尝试了以下命令

  • npm安装

  • npm install

npm install @angular/{animations,common,compiler,compiler-cli,
            core,forms,http,platform-browser,platform-browser-dynamic,
            platform-server,router}@5.0.0

  • 纱线安装

  • yarn installation

    yarn add @angular/{animations,common,compiler,compiler-cli,
             core,forms,http,platform-browser,platform-browser-dynamic,
             platform-server,router}@5.0.0
    

  • 尝试了更新指南

     npm install @angular/animations@'^5.0.0' @angular/common@'^5.0.0'
            @angular/compiler@'^5.0.0' @angular/compiler-cli@'^5.0.0'
            @angular/core@'^5.0.0' @angular/forms@'^5.0.0'
            @angular/http@'^5.0.0' @angular/platform-browser@'^5.0.0'
            @angular/platform-browser-dynamic@'^5.0.0'
            @angular/platform-server@'^5.0.0' @angular/router@'^5.0.0'
            [email protected] rxjs@'^5.5.2'
    
     npm install [email protected] --save-exact
    

  • 对我来说,一切都没有问题.请帮助

    Nothing worked fine for me. Please help

    推荐答案

    您需要按以下方式将所有提供的angular软件包更新为最新版本:

    You need to update all angular provided packages to their latest versions as follows:

    npm install [email protected] --save-dev
    
    npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest --save
    

    这应该做所有必要的事情.另外,您还可以按照以下标准更新随角度5一起提供的角度cli:

    This should do all the necessary. Plus you could also update your angular cli that ships with angular 5 as standard version as follows:

    npm uninstall -g @angular/cli
    npm cache clean
    npm install -g @angular/cli@latest
    

    这是Angular团队的官方博客文章: https://angular-update-guide.firebaseapp. com/.此更新指南将帮助您从任何版本迁移到最新版本.

    Here is the official blogpost by Angular team : https://angular-update-guide.firebaseapp.com/. This update guide will help you to migrate from any version to the latest one.

    这篇关于将Angular 4.x迁移到Angular 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    08-12 17:54