gpt4 book ai didi

javascript - This version of CLI is only compatible with Angular version 5.0.0 or higher 错误

转载 作者:太空狗 更新时间:2023-10-29 18:28:46 24 4
gpt4 key购买 nike

我已经有在 4 版本中运行的 Angular 项目。在安装新项目时,不幸的是我安装了 6 个版本的 angular cli。在以 4 版本运行的旧项目中运行 ng serve 命令时,这会抛出一个错误“您的全局 Angular CLI 版本大于您的本地版本”。我再次尝试更新我的 Anglar 本地版本。但是现在我得到了一个错误 This version of CLI is only compatible with Angular version 5.0.0 or higher.我的 package.json 如下:

 {
"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 天,但我找不到任何合适的解决方案。

最佳答案

我想这就是您要找的。其他答案只是忘记包含 -g 参数。

npm install -g @angular/cli@1.4.9

这一切都在错误本身中说明了。您没有在全局范围内安装它;)希望这能解决您的问题。

更新:要将 Angular CLI 更新到新版本,您必须同时更新全局包和项目的本地包。

全局包:

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

本地项目包:

// 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

更多info查看 GitHub 上的自述文件。

关于javascript - This version of CLI is only compatible with Angular version 5.0.0 or higher 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52176881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com