How do I correctly upgrade angular 2 (npm) to the latest version?

前端 未结 11 1519
予麋鹿
予麋鹿 2020-11-28 00:47

Recently I started Angular 2 tutorial at https://angular.io/docs/ts/latest/tutorial/.

and left off with Angular 2 beta 8. Now I resumed the tutorial and latest beta

11条回答
  •  孤独总比滥情好
    2020-11-28 01:36

    UPDATE:
    Starting from CLI v6 you can just run ng update in order to get your dependencies updated automatically to a new version.

    With ng update sometimes you might want to add --force flag. If you do so make sure that the version of typescript you got installed this way is supported by your current angular version, otherwise you might need to downgrade the typescript version.

    Also checkout this guide Updating your Angular projects


    For bash users only

    If you are on are on Mac/Linux or running bash on Windows(that wont work in default Windows CMD) you can run that oneliner:

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

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

    Just specify version you wan't e.g @4.4.5 or put @latest to get the latest

    Check your package.json just to make sure you are updating all @angular/* packages that you app is relying on

    • To see exact @angular version in your project run:
      npm ls @angular/compiler or yarn list @angular/compiler
    • To check the latest stable @angular version available on npm run:
      npm show @angular/compiler version

提交回复
热议问题