您的全局Angular CLI版本大于本地版本

时间:2018-01-18 08:14:44

标签: angular angular-cli

我在新机上安装了最新的angular-cli,我正在尝试使用之前的cli版本生成项目

我收到了这个警告

Your global Angular CLI version (1.6.4) is greater than your local
version (1.6.3). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".

虽然项目正常运作我为了用最新的dependecies更新我的项目并避免这个消息(避免不抑制!)

这是我的package.json

{
    "name": "AngularTest",
    "version": "0.0.0",
    "license": "MIT",
    "angular-cli": {},
    "scripts": {
        "ng": "ng",
        "start": "ng serve --host 0.0.0.0 --port 4200",
        "hmr": "ng serve --host 0.0.0.0 --port 4200 4201 --hmr -e=hmr",
        "test": "ng test",
        "pree2e": "webdriver-manager update --standalone false --gecko false",
        "e2e": "protractor"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "^5.0.3",
        "@angular/common": "^5.0.3",
        "@angular/compiler": "^5.0.3",
        "@angular/core": "^5.0.3",
        "@angular/forms": "^5.0.3",
        "@angular/http": "^5.0.3",
        "@angular/platform-browser": "^5.0.3",
        "@angular/platform-browser-dynamic": "^5.0.3",
        "@angular/router": "^5.0.3",
        "@aspnet/signalr-client": "1.0.0-preview1-27891",
        "@types/bootstrap": "^3.3.33",
        "@types/jquery": "^3.2.12",
        "@types/jquery.blockui": "0.0.28",
        "@types/jquery.validation": "^1.16.3",
        "@types/lodash": "^4.14.62",
        "@types/moment": "^2.13.0",
        "@types/moment-timezone": "^0.2.34",
        "@types/signalr": "^2.2.33",
        "@types/toastr": "^2.1.33",
        "abp-ng2-module": "^1.3.0",
        "abp-web-resources": "^3.3.0",
        "animate.css": "^3.5.2",
        "block-ui": "^2.70.1",
        "bootstrap": "^3.3.7",
        "bootstrap-select": "^1.12.2",
        "chart.js": "^2.6.0",
        "core-js": "^2.4.1",
        "famfamfam-flags": "^1.0.0",
        "flot": "^0.8.0-alpha",
        "font-awesome": "^4.7.0",
        "jquery": "^3.1.1",
        "jquery-countto": "^1.2.0",
        "jquery-migrate": "^3.0.0",
        "jquery-slimscroll": "^1.3.8",
        "jquery-sparkline": "^2.4.0",
        "js-cookie": "^2.1.4",
        "lodash": "^4.17.4",
        "moment": "^2.18.1",
        "moment-timezone": "^0.5.13",
        "morris.js": "^0.5.0",
        "ngx-bootstrap": "^1.6.6",
        "ngx-pagination": "^3.0.0",
        "node-waves": "^0.7.5",
        "push.js": "1.0.4",
        "raphael": "^2.2.7",
        "rxjs": "^5.5.2",
        "signalr": "^2.2.1",
        "simple-line-icons": "^2.4.1",
        "spin.js": "^2.3.2",
        "sweetalert": "^2.0.8",
        "toastr": "^2.1.2",
        "ts-helpers": "^1.1.2",
        "web-animations-js": "^2.3.1",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@angular/cli": "^1.5.4",
        "@angular/compiler-cli": "^5.0.3",
        "@angularclass/hmr": "^2.1.3",
        "@types/jasmine": "^2.5.38",
        "@types/node": "^8.0.27",
        "codelyzer": "^3.1.2",
        "jasmine-core": "^2.5.2",
        "jasmine-spec-reporter": "^4.2.1",
        "karma": "^1.4.1",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-coverage-istanbul-reporter": "^1.3.0",
        "karma-jasmine": "^1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "nswag": "^11.12.7",
        "protractor": "^5.1.1",
        "ts-node": "^3.3.0",
        "tslint": "^5.7.0",
        "typescript": "2.4.2"
    }
}

6 个答案:

答案 0 :(得分:1)

警告显示您的本地应用程序cli版本低于全局cli版本。因此,如果您想要停止该警告,则需要在本地安装特定的角度cli版本。

使用此命令

UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil)

在你的情况下

npm install --save @angular/cli@wished.version.here

答案 1 :(得分:1)

Your global Angular CLI version (6.0.0) is greater than your local version (1.6.1). The local Angular CLI version is used

您可以使用以下方法将本地版本更新为最新版本:

npm uninstall --save-dev angular/cli
npm install --save-dev @angular/cli@latest
npm install

验证版本

  ng --version

答案 2 :(得分:1)

我有同样的问题。我手动将package.json更新为" @ angular / cli":" ^ 6.0.0"并在发出npm install @ angular / cli之前删除了node_modules / @ angular / cli模块。

这解决了这个问题。

答案 3 :(得分:1)

您需要升级项目用户的CLI版本。 我建议进行备份,然后: 1-确保您位于项目文件夹中。 2-运行

ng update --all

更新所有软件包,或者您可以运行

ng update @angular/core

仅用于升级核心软件包,但我建议升级所有软件包。

此后,您可以正常运行应用程序。

答案 4 :(得分:1)

安装的本地 Angular CLI 版本比最新的稳定版本旧。 安装了一个临时版本来执行更新。

解决方案

npm install --save @angular/cli@(latest version) -g

如果我们假设我们想要 Angular 版本 10.2.0 我们将编写命令:

npm install --save @angular/cli@10.2.0 -g

答案 5 :(得分:0)

如果您收到此消息

“您的全局Angular CLI版本(6.0.0)大于本地版本(1.6.1)。使用的是本地Angular CLI版本。”

您只需要将本地版本更新为全局版本即可。

首先键入命令 npm卸载--save-dev angular / cli

让它卸载当前版本

然后 npm install --save-dev @ angular / cli @ latest

现在,它已更新为最新版本。 要检查,只需运行命令 ng --version

现在全部设置好了... 转到终端并输入 ng服务

谢谢, 加尼