如何使用 CLI 创建特定版本的 Angular 项目? [英] How to Create a specific version of Angular Project using CLI?

查看:53
本文介绍了如何使用 CLI 创建特定版本的 Angular 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的npm 版本是 5.5.1angular 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 无法创建特定的 Angular 版本.

Using CLI you can not create specific angular version.

但是您可以将特定版本的 angular 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.

然后在 Command Prompt(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.

现在输入 angular 特定版本命令: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:\projects\demo\.

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 创建 Angular 项目,它将创建您的特定 Angular 版本 项目.

Now create angular project using the command ng new Project_name and it will create your specific angular version Project.

在我的示例中,它将创建 angular 5 项目.

In my example it will create angular 5 project.

这篇关于如何使用 CLI 创建特定版本的 Angular 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆