【问题标题】:Angular 4 installation issueAngular 4 安装问题
【发布时间】:2019-05-01 05:56:35
【问题描述】:

我已经在我的系统中安装了节点 6.10.0,我还想安装 angular 4。 我正在使用命令 npm install -g @angular/cli@1.4 但我无法这样做。需要一些建议。 PS:我用的是windows

【问题讨论】:

  • 您能具体说明问题吗?例如,您会遇到什么错误?
  • “但我做不到”...为什么?
  • 首先全局安装最新的 Angular。比在特定文件夹中安装 angular 4 之后。参考这个链接:stackoverflow.com/questions/52331625/…

标签: node.js angular


【解决方案1】:

首先从您的 cli 安装最新版本。然后在 package.json 的“依赖项”部分中指定您想要的版本。例如,如果你想要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 版本

【讨论】:

    猜你喜欢
    • 2013-05-30
    • 2020-03-22
    • 1970-01-01
    • 2017-09-20
    • 2016-04-07
    • 2021-05-10
    • 1970-01-01
    • 2017-06-27
    • 1970-01-01
    相关资源
    最近更新 更多