简体   繁体   English

Angular Cli和Angular 2

[英]Angular Cli and Angular 2

I want to use angular 2 in my project (note angular 4 is not approved in my company yet so can't use it). 我想在我的项目中使用角度2(注意角度4在我公司尚未批准,所以不能使用它)。 Also, want to use Angular-CLI to generate and create angular code. 此外,还想使用Angular-CLI生成和创建角度代码。 At the moment, angular-cli by default uses angular4 and I don't want that. 目前,angular-cli默认使用angular4,我不希望这样。 Is it possible to use angular-cli to install angluar2 version? 是否可以使用angular-cli来安装angluar2版本?

Thanks. 谢谢。

Of course, you can, but you will have to work with one of the latest betas of angular-cli. 当然,你可以,但你必须使用angular-cli的最新测试版之一。

As far as I see you could use angular-cli v1.0.0-beta.32 which will install 2.4 据我所知,你可以使用angular-cli v1.0.0-beta.32,它将安装2.4

https://github.com/angular/angular-cli/tree/v1.0.0-beta.32 https://github.com/angular/angular-cli/tree/v1.0.0-beta.32

For installation steps use windows PowerShell (Run as admin) than normal command prompt to avoid permission issues. 对于安装步骤,请使用Windows PowerShell(以管理员身份运行)而不是正常命令提示符,以避免权限问题。

o Node install • Make sure you have updated node installed .At least 6.1.If yes ,skip this step. o节点安装•确保已安装更新的节点。至少6.1。如果是,请跳过此步骤。 If no please download latest from https://nodejs.org/en/ • After installation check node version node -v. 如果没有请从https://nodejs.org/en/下载最新版本•安装后检查节点版本节点-v。 And it should be 6.1 at least 它至少应该是6.1

o Npm upgrade • After node installed check npm version npm -v • At least 4.4 should be present .If yes ,skip this step. o Npm升级•节点安装后检查npm版本npm -v•至少应该存在4.4。如果是,请跳过此步骤。 If no please upgrade it using below commands and select 4.4 from the menu 如果没有,请使用以下命令升级它,然后从菜单中选择4.4

 Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force  npm install --global --production npm-windows-upgrade  npm-windows-upgrade Set-ExecutionPolicy Unrestricted -Scope CurrentUser-Forcenpminstall --global --production npm-windows-upgradenpm-windows-upgrade

• Now check version npm -v . •现在检查版本npm -v。 It should be 4.4 now 现在应该是4.4

o Angular CLI set up • Once npm is ready then install angular CLI using below command  npm -g install angular-cli@latest (installing globally .So no need to point any folder in cmd prompt) • If u have already installed angular CLI .please run below command to get updated version . o Angular CLI设置•一旦npm准备就绪,然后使用以下命令安装angular CLInpm-g install angular-cli @ latest(全局安装。所以不需要在cmd提示符中指向任何文件夹)•如果你已经安装了角度CLI .please运行命令以获取更新版本。

 npm uninstall -g angular-cli  npm cache clean  npm install -g angular-cli@latest npmuninstall -g angular-clinpmcachecleannpminstall -g angular-cli @ latest

• Once done please check angular cli version using ng -v . •完成后,请使用ng -v检查角度cli版本。 At least 1.0.0-beta.24 should be present. 应该至少存在1.0.0-beta.24。

• App creation We can create app using command prompt and IDE's. •应用程序创建我们可以使用命令提示符和IDE创建应用程序。 Currently Intellij supporting angular CLI to create angular 2 app. 目前Intellij支持角度CLI来创建angular 2 app。 So for other domain developers we have to go with command prompt . 因此,对于其他域开发人员,我们必须使用命令提示符。

o Create angular 2 app (Command prompt) • Create some brand new project folder in your system .That will be treated as your project folder • Point to that in windows normal command prompt (No need of PowerShell). o创建角度2应用程序(命令提示符)•在系统中创建一个全新的项目文件夹。这将被视为您的项目文件夹•指向Windows正常命令提示符(不需要PowerShell)。 • Run this command ng init. •运行此命令ng init。 Will take good time to complete. 将花时间完成。 Make sure you are pointed to your project folder before run this cmd. 在运行此cmd之前,请确保指向项目文件夹。 • It will create project structure and download all the basic dependencies to run the angular 2 app. •它将创建项目结构并下载所有基本依赖项以运行angular 2应用程序。 • After project creation run ng serve to run the application . •项目创建运行后,用于运行应用程序。 o Create angular 2 app (Intellij) • Add angular CLI plugin to your Intellij • File -> new ->static web-> Angular CLI . o创建angular 2 app(Intellij)•将角度CLI插件添加到Intellij•文件 - >新建 - >静态Web-> Angular CLI。 This will run the above mentioned commands to create angular 2 app 这将运行上面提到的命令来创建angular 2应用程序

For commands related to angular CLI 对于与角度CLI相关的命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM