Angular 6: How to install a previous version of Angular project

左心房为你撑大大i 提交于 2019-12-07 08:56:55

问题


How I can install a previous version of Angular project with the current Angular-cli version (Angular 6).

I found a command but is deprecated:

ng new my_project --ng4


回答1:


Since you want to use angular-cli to create new project, you need to install the version of @angular/cli that scaffolds angular 4 project.

Version of @angular/cli which scaffolds the Angular 4 project is 1.4.9.

So, using npm, do npm install @angular/cli@1.4.9, then use angular-cli commands.




回答2:


You can just have package.json with specific version and do npm install and it will install that version. Also you dont need to depend on angular-cli to develop your project.

Other thing is you can remove the latest version of angular-cli and install minor version of it. Then create the project.

Let me explain:

[STEP 0 - OPTIONAL] If you're not sure of the angular-cli version installed in your environment, uninstall it.

npm uninstall -g @angular/cli

Then, run

npm cache clean

or, if you're using npm > 5

npm cache verify

[STEP 1] Install an angular-cli specific version

npm install -g @angular/cli@wished.version.here

[STEP 2] Create a project

ng new you-app-name

The resulting white app will be created in the desired angular version.




回答3:


I found a better answer for me. I share it with you:

How to install Angular 2:

npm install @angular/cli@1.0.0-beta.33.1 This install the 2.4.0 version

How to install Angular 4:

npm install @angular/cli@1.4 This install the 4.2.4 version

How to install Angular 5:

npm install @angular/cli@1 This install @angular/cli@1.5

All this installations it must be installed as local projects dependencies

I hope you find it useful.



来源:https://stackoverflow.com/questions/50272621/angular-6-how-to-install-a-previous-version-of-angular-project

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