[英]angular cli doesn't create the Component
For below command:对于以下命令:
ng generate component mycomponent
it is just consoling this errored message as below:它只是安慰此错误消息,如下所示:
Cannot read property 'NullLogger' of undefined TypeError: Cannot read property 'NullLogger' of undefined
无法读取未定义的属性“NullLogger”类型错误:无法读取未定义的属性“NullLogger”
Look at https://github.com/angular/angular-cli/issues/9303 it seems to be a version issue :看https://github.com/angular/angular-cli/issues/9303好像是版本问题:
Please first uninstall all versions and clear the cache, and after install:
ng install -g @angular/cli@1.4.10
使用以下命令安装最新的 angular cli: npm install --save @angular/cli@latest
Below package.json with corresponding dependencies should work:下面的 package.json 具有相应的依赖项应该可以工作:
{
"name": "angular-tour-of-heroes",
"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/animations": "^4.3.1",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@types/jquery": "^2.0.45",
"angular2-tooltip": "^3.1.0",
"angular2-websocket-service": "^0.5.3",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"ng2-stomp-service": "^1.2.2",
"ng2-toastr": "^4.0.1",
"ngx-toastr": "^8.7.3",
"queueing-subject": "^0.1.1",
"rxjs": "^5.1.0",
"sockjs-client": "1.0.0",
"stompjs": "^2.3.3",
"tslib": "^1.9.2",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/bootstrap": "^3.3.33",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"angular-ide": "^0.9.22",
"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.2.0"
}
}
Place this package.json in your project root and just run the below command again:将此 package.json 放在您的项目根目录中,然后再次运行以下命令:
npm install
and then进而
ng generate component mycomponent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.