加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular:升级到版本5错误:@ angular / compiler-cli的版本需要

发布时间:2020-12-17 08:52:36 所属栏目:安全 来源:网络整理
导读:放弃 可能重复this,但详细问题没有显示有问题的特定错误消息,因此它含糊不清且无益.当我在Google中输入错误时,我根本无法找到它,这是因为他的问题在任何地方都没有包含错误. 除非为了清楚起见编辑了其他问题,否则请不要关闭此问题,因为相关错误没有其他结果.
放弃

可能重复this,但详细问题没有显示有问题的特定错误消息,因此它含糊不清且无益.当我在Google中输入错误时,我根本无法找到它,这是因为他的问题在任何地方都没有包含错误.

除非为了清楚起见编辑了其他问题,否则请不要关闭此问题,因为相关错误没有其他结果.

尝试在升级到v5后运行ng服务,但是出现了一些错误.谁知道怎么了?根据package.json,我的@ angular / compiler-cli是5.0.0 …不确定为什么它说5.0.0小于2.3.1.

这是我的升级命令:

npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@5.0.0

我收到以下错误:

$ng serve
Your global Angular CLI version (1.5.0) is greater than your local
version (1.0.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
Version of @angular/compiler-cli needs to be 2.3.1 or greater. Current version is "5.0.0".
Error: Version of @angular/compiler-cli needs to be 2.3.1 or greater. Current version is "5.0.0".
    at Object.<anonymous> (REDACTED/node_modules/@ngtools/webpack/src/index.js:27:11)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (REDACTED/node_modules/@angular/cli/tasks/eject.js:10:19)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)

这是package.json:

{
    "name": "App","version": "0.0.0","license": "MIT","scripts": {
        "ng": "ng","start": "ng serve","start-hmr": "ng serve --hmr -e=hmr","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e"
    },"private": true,"dependencies": {
        "@angular/animations": "^5.0.0","@angular/common": "^5.0.0","@angular/compiler": "^5.0.0","@angular/core": "^5.0.0","@angular/forms": "^5.0.0","@angular/http": "^5.0.0","@angular/platform-browser": "^5.0.0","@angular/platform-browser-dynamic": "^5.0.0","@angular/platform-server": "^5.0.0","@angular/router": "^5.0.0","@angularclass/hmr": "^1.2.2","@types/jquery": "^2.0.48","@types/lodash": "^4.14.73","angular2-moment": "^1.7.0","bootstrap": "^3.3.7","core-js": "^2.5.0","jquery": "^3.2.1","lodash": "^4.17.4","particles.js": "^2.0.0","rxjs": "^5.5.2","zone.js": "^0.8.16"
    },"devDependencies": {
        "@angular/cli": "1.0.0","@angular/compiler-cli": "5.0.0","@types/jasmine": "2.5.38","@types/node": "^6.0.87","codelyzer": "~2.0.0","jasmine-core": "~2.5.2","jasmine-spec-reporter": "~3.2.0","karma": "~1.4.1","karma-chrome-launcher": "~2.0.0","karma-cli": "~1.0.1","karma-coverage-istanbul-reporter": "^0.2.0","karma-jasmine": "~1.1.0","karma-jasmine-html-reporter": "^0.2.2","protractor": "~5.1.0","ts-node": "~2.0.0","tslint": "~4.5.0","typescript": "~2.4.2"
    }
}
在这种情况下,您需要将@ angular / cli的本地安装从1.0.0更新到1.5.0. CLI的许多次要版本包括许多更改,以及随这些更新而来的依赖项的更改.

要将CLI的本地版本更新到最新版本,请在命令提示符/终端中使用以下命令,打开该项目的根目录.

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

或者,您只需更新package.json中的版本,然后运行npm install.

当全局和本地CLI版本不同步时,您可以隐藏CLI显示的警告,但这可能会隐藏您遇到的任何问题的解决方案.要隐藏警告,请运行以下命令:

ng set --global warnings.versionMismatch=false

最好保持本地和全球版本同步,以避免出现问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读