创建新组件时我现在遇到错误
ng g componenet testComponent
错误是
Cannot read property 'NullLogger' of undefined
TypeError: Cannot read property 'NullLogger' of undefined
at SchematicEngine.createContext (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular-devkit\schematics\src\engine\engine.js:75:39)
at SchematicImpl.call (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular-devkit\schematics\src\engine\schematic.js:35:38)
at Promise (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular\cli\tasks\schematic-run.js:77:23)
at new Promise (<anonymous>)
at Class.run (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular\cli\tasks\schematic-run.js:76:16)
at Class.run (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular\cli\commands\generate.js:149:33)
at resolve (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular\cli\ember-cli\lib\models\command.js:261:20)
at new Promise (<anonymous>)
at Class.validateAndRun (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular\cli\ember-cli\lib\models\command.js:240:12)
at Promise.resolve.then.then (d:\Nodejs Workarea\sherif negm\blur\back-end\angular\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:140:24)
角度-g -v是
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.4.5
node: 10.8.0
os: win32 x64
@angular/animations: 4.4.7
@angular/common: 4.4.7
@angular/compiler: 4.4.7
@angular/core: 4.4.7
@angular/forms: 4.4.7
@angular/http: 4.4.7
@angular/platform-browser: 4.4.7
@angular/platform-browser-dynamic: 4.4.7
@angular/router: 4.4.7
@angular/cli: 1.4.5
@angular/compiler-cli: 4.4.7
@angular/language-service: 4.4.7
typescript: 2.3.4
我项目中的依赖项是
"dependencies": {
"@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",
"angular-sortablejs": "^2.5.2",
"core-js": "^2.4.1",
"ng2-bearer": "^0.1.28",
"rxjs": "^5.4.2",
"sortablejs": "^1.7.0",
"zone.js": "^0.8.14"
},
在我将angular更新为6,然后再次降级为以前的版本4之后,此错误正在显示给我。
请不要更新项目的角度。
答案 0 :(得分:0)
我已经通过将@ angular / cli的全局升级和项目依赖性升级到@ angular / cli:1.4.10解决了这个问题
答案 1 :(得分:0)
以下步骤对我有用,
npm卸载-g @ angular / cli
npm卸载--save-dev @ angular / cli
清除缓存,
npm缓存验证
npm install -g @ angular / cli @ latest
npm install --save-dev @ angular / cli @ latest