How to downgrade Angular CLI version?

自古美人都是妖i 提交于 2020-07-16 16:35:09

问题


I'm new in Angular 4 and I am getting this error,

Your global Angular CLI version (6.0.1) is greater than your local
version (1.4.1). The local Angular CLI version is used.

Can you please help me solving this ?


回答1:


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



回答2:


Quick fix :

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

Explanation :

If you want remove this warning, then you can downgrade your global angular-cli installation to eg. 1.4.1 by running above commands on terminal:

Complete Upgrade and Downgrade guide is on GitHub README.

Your project always uses CLI version on which you have created the project. You can see it in the warning while running ng serve.

If global version is greater than Local version then local version is used.

It is also defined in your package.json file.

"devDependencies": {
    "@angular/cli": "1.5.0",
     ....
} 

Reference Link




回答3:


1) Do you have other projects which are using angular (and what version of CLI are they using)

2) Once you identify which version you want to retain, you can uninstall the current version by

global:

npm uninstall -g @angular/cli

or local

npm uninstall @angular/cli

3) Then install desired version in the same scope as you uninstalled (making sure of any dependencies with other components)

global

specific version

npm install -g @angular/cli@1.4.1

latest version

npm install -g @angular/cli

local Same as global but without the "-g" flag

Ideally the versions should be latest unless you figure out any compatibility issues

Edit:

Angular CLI 6.xxx

has a breaking change of "angular.json" in new vs ".angular.json" in old (difference of dot in file name). Use Error: Local workspace file ('angular.json') could not be found if moving to angular 6



来源:https://stackoverflow.com/questions/50363530/how-to-downgrade-angular-cli-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!