无法读取属性' NullLogger'未定义的(角度/ cli 1.4.7)

时间:2018-02-01 16:29:00

标签: angular angular-cli

今天,sudeenly我开始得到这个错误 "无法读取属性' NullLogger'在我的angular 4应用程序中尝试添加组件(ng g c abc)时未定义" 。当我在谷歌搜索它时,人们建议我们需要将我们的cli版本更新到1.4.10。但问题是为什么我们现在为1.4.10以下的所有angular / cli版本得到此错误?。我现在不想更新我的CLI版本。有谁知道它为什么会发生?

以下是我的package.json文件,

"dependencies": { "@angular/animations": "^4.4.6", "@angular/common": "^4.4.6", "@angular/compiler": "^4.4.6", "@angular/core": "^4.4.6", "@angular/forms": "^4.4.6", "@angular/http": "^4.4.6", "@angular/platform-browser": "^4.4.6", "@angular/platform-browser-dynamic": "^4.4.6", "@angular/router": "^4.4.6", "angular2-csv": "^0.2.5", "bootstrap": "^3.3.7", "classlist.js": "^1.1.20150312", "core-js": "^2.4.1", "font-awesome": "^4.7.0", "jquery": "^3.2.1", "lodash": "^4.17.4", "ng-select": "^1.0.0-rc.3", "ng2-dragula": "^1.5.0", "reflect-metadata": "^0.1.10", "rxjs": "^5.4.2", "toastr": "^2.1.2", "underscore": "^1.8.3", "web-animations-js": "^2.3.1", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.4.7", "@angular/compiler-cli": "^4.4.6", "@angular/language-service": "^4.4.6", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "@types/toastr": "^2.1.35", "codelyzer": "~3.2.0", "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.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "^2.3.4" }

2 个答案:

答案 0 :(得分:19)

我确实关注了这个问题,

全局卸载@ angular / cli

npm uninstall -g @angular/cli

在本地卸载@ angular / cli

npm uninstall --save-dev @angular/cli

清除缓存,

npm cache clean

全局和本地安装@ angular / cli

npm install -g @angular/cli@latest

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

之后全部工作。

答案 1 :(得分:1)

我也收到了这个错误。 不幸的是,接受的答案对我没有帮助。

所以我需要安装最新版本的Node.js.然后再次安装CLI:

  

npm install -g @ angular / cli @ latest

之后问题得到解决。