如何使用Angular v4.x安装Angular-CLI [英] How to install Angular-CLI with Angular v4.x

查看:82
本文介绍了如何使用Angular v4.x安装Angular-CLI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用此命令安装了Angular-CLI

I've installed Angular-CLI using this command

npm install -g @angular/cli

但是我已经意识到它已经安装了Angular v5.1.3,但是我需要使用Angular 4.x.

but I've realized that it has installed Angular v5.1.3 but I need to use Angular 4.x.

如何将最新版本的Angular-CLI与最新版本的Angular 4.x一起安装?

How can I install the last version of Angular-CLI with the last version of Angular 4.x?

推荐答案

我认为将cli降级不是一个好主意,因为它们正在修复许多错误.您可以在package.json文件中指定角度.不要依赖您的cli.

I think downgrade your cli is not good idea becuase they are fixing lots of bug. You can specific your angular in package.json file. don't depend on your cli.

首先从cli安装最新版本.然后在package.json的"dependencies"部分中指定所需的版本.例如,如果您想要Angular 4.3.4,则可以编辑package.json文件,例如

First install latest version from your cli. Then Specify the version you want in the 'dependencies' section of your package.json. For example if you want Angular 4.3.4 then you can edit you package.json file like

"dependencies": {
    "@angular/animations": "^4.3.4",
    "@angular/common": "^4.3.4",
    "@angular/compiler": "^4.3.4",
    "@angular/core": "^4.3.4",
    "@angular/forms": "^4.3.4",
    "@angular/http": "^4.3.4",
    "@angular/platform-browser": "^4.3.4",
    "@angular/platform-browser-dynamic": "^4.3.4",
    "@angular/router": "^4.3.4",
     ...........................
     ...........................
    }

还要更改您的devDependencies

    "devDependencies": {
      "@angular/compiler-cli": "^4.3.4",
      "@angular/language-service": "^4.3.4",
      .............
    }

现在运行npm install

now run npm install

  npm install

完成安装后,您应通过ng -v这样的命令查看版本

After finishing install you should see your version by ng -v command like this

Angular CLI: 1.6.3
Node: 9.3.0
OS: linux x64
Angular: 4.4.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, tsc-wrapped

@angular/cli: 1.6.3
@angular-devkit/build-optimizer: 0.0.38
@angular-devkit/core: 0.0.25
@angular-devkit/schematics: 0.0.48
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.13
@schematics/schematics: 0.0.13
typescript: 2.4.2
webpack: 3.10.0

这篇关于如何使用Angular v4.x安装Angular-CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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