Can not read property 'NullLogger' of unde

2019-05-03 09:36发布

问题:

Today, sudeenly I start getting this error "Cannot read property 'NullLogger' of undefined" while trying to add a component ( ng g c abc) in my angular 4 app. When I searched it on google, people are suggesting that we need to update our cli version to 1.4.10 . But the question is why we are getting this error now for all angular/cli version below 1.4.10? . I do not want to update my CLI version now. Does anyone know why is it happening??

Following is my package.json file,

"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" }

回答1:

I did following to resolve the issue,

Uninstall @angular/cli globally

npm uninstall -g @angular/cli

Uninstall @angular/cli locally

npm uninstall --save-dev @angular/cli

clear cache,

npm cache clean

install @angular/cli globally and locally again

npm install -g @angular/cli@latest

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

All worked after that.



回答2:

I received this error also. The accepted answer unfortunately didn't help me.

So I needed to install the newest version of Node.js. And install CLI again:

npm install -g @angular/cli@latest

After that the the issue was resolved.