Angular 4安装问题

时间:2018-11-29 08:13:59

标签: node.js angular

我已经在系统中安装了节点6.10.0,并且我还想安装angular 4。 我正在使用命令     npm install -g @ angular / cli @ 1.4 但是我做不到。需要一些建议。 PS:我使用Windows

1 个答案:

答案 0 :(得分:0)

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

"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

 npm install

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

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

PS:从您的问题中,您已经提到npm install -g @angular/cli@1.4尝试安装 angular 4

时没有1.4版本。