此版本的CLI仅与Angular 5.0.0或更高版本的错误兼容 [英] This version of CLI is only compatible with Angular version 5.0.0 or higher error

查看:539
本文介绍了此版本的CLI仅与Angular 5.0.0或更高版本的错误兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有在4版本中运行过的Angular项目。在安装新项目时,不幸的是我已经安装了6版本的cli。在运行以4版本运行的旧项目中运行ng serve命令时,出现一个错误消息您的全局Angular CLI版本大于您的本地版本。我再次尝试更新我的anglar本地版本。但是现在我遇到了错误。此版本的CLI仅与Angular 5.0.0或更高版本兼容。我的package.json如下:

I already had angular project that ran in 4 version. While installing new project, unfortunately i have installed 6 version of angular cli. This throw me an error 'Your global Angular CLI version is greater than your local version' while running ng serve command in old project that ran in 4 version. Again i tried to update my anglar local version. But now i have got an error This version of CLI is only compatible with Angular version 5.0.0 or higher. My package.json is following:

 {
  "name": "authority-client",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/core": "^0.7.2",
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "@types/file-saver": "^1.3.0",
    "angular2-cookie": "^1.2.6",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.8",
    "ng2-toastr": "^4.1.2",
    "ngx-bootstrap": "^2.0.1",
    "ngx-loading": "^1.0.14",
    "npm": "^5.5.1",
    "postcss-loader": "^2.0.9",
    "rxjs": "^5.4.2",
    "sweetalert2": "^7.22.0",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "^6.1.5",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@ngtools/webpack": "^6.1.5",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-ide": "^0.9.44",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.0",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

有人可以解决此错误。我已经从最近2天开始尝试过,但是我找不到任何合适的解决方案。

Can someone fix this error. I have been tried from last 2 days, but i cant find any appropriate solution.

推荐答案

我认为这就是你要的寻找。
其他答案只是忘记了包含 -g 参数。

I think this is what you're looking for. Other answers simply forgot to include the -g parameter.

npm install -g @ angular / cli @ 1.4.9

npm install -g @angular/cli@1.4.9

全部都在错误本身中说明。您不是在全球范围内安装它;)
希望这能解决您的问题。

It's all said in the error itself. You're not installing it globally ;) Hope this solves your issues.

更新:
更新Angular CLI升级到新版本,必须同时更新全局软件包和项目的本地软件包。

UPDATE: To update Angular CLI to a new version, you must update both the global package and your project's local package.

npm uninstall -g @angular/cli
npm cache verify // If npm version is < 5 then use `npm cache clean`
npm install -g @angular/cli@latest



本地项目包:



Local project package:

// Use rmdir /S/Q node_modules dist in Windows Command Prompt; 
// Use rm -r -fo node_modules, dist in Windows PowerShell

rm -rf node_modules dist 
npm install --save-dev @angular/cli@latest
npm install

更多信息在GitHub上查看自述文件。

For more info check out the ReadMe file on GitHub.

这篇关于此版本的CLI仅与Angular 5.0.0或更高版本的错误兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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