如何使用CLI创建特定版本的Angular Project? [英] How to Create a specific version of Angular Project using CLI?
问题描述
我的 npm版本是5.5.1 ,角度cli版本是6.2.1 。当我尝试使用命令 ng new Project_name 创建新项目时,它正在创建angular的最新版本(以我为例,它正在创建Angular版本^ 6.1.0 )。但是我想要Angular4 。
我的问题是 如何创建此Angualr2 / 4/5(特定版本而不是最新版本)?
我不认为要更改在我的情况下, package.json 中的版本值会有所帮助,因为旧版本和最新版本6之间存在一些差异(例如,一个文件的名称已从angular-cli.json更改为anguar.json不仅会更改名称,而且内容也会更改。)
我也在Angular-cli Github网站中也提出了同样的问题。单击此处
My npm version is 5.5.1 and angular cli version is 6.2.1. When I try to create a new project using the command ng new Project_name then it is creating the latest version of angular (in my case it is creating Angular version ^6.1.0). But I want Angular4. My question is how to create this Angualr2/4/5 (specific version instead of the latest version)? I don't think changing the version value in package.json will help in my case because there are some differences in the older versions and the latest 6 version (like the name of one file has been changed from angular-cli.json to anguar.json and not only name but content is also changed.) I've also raised the same question in Angular-cli Github site as well. click here
谢谢!
推荐答案
使用CLI不能创建特定的角度版本。
Using CLI you can not create specific angular version.
但是您可以将特定版本的角度CLI安装到
But you can install specific version of angular CLI into particular folder.
例如:
第一个在任何驱动器中创建新文件夹
。我将在D盘中创建演示文件夹。例如: d:\projects\demo
。
First create new folder
inside any drive. I'm going to create demo folder in D drive. Ex: d:\projects\demo
.
然后在内找到此文件夹命令提示符(cmd)
或只需在Windows中创建的文件夹地址栏中键入 cmd
并按Enter。
Then find this folder inside Command Prompt(cmd)
or just type cmd
into your created folder addressbar in windows and hit enter.
现在输入特定于角度的版本命令: npm install @ angular / cli @ 1.7.x
获取angular 5,其他版本使用类似的命令。
Now type angular specific version command : npm install @angular/cli@1.7.x
for angular 5. and use similar command for other version.
完成安装后,只需在新安装的angular文件夹中创建新的angular项目。例如: d:\projectsdemo\
。
After complete the installation, just create new angular project into your specific folder that you recently install angular. Ex: d:\projects\demo\
.
现在使用命令 ng new Project_name
创建角度项目,它将创建您特定的角版本
项目。
Now create angular project using the command ng new Project_name
and it will create your specific angular version
Project.
在我的示例中,它将创建角度为5的项目。
In my example it will create angular 5 project.
这篇关于如何使用CLI创建特定版本的Angular Project?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!