angular cli报错:TypeError: Cannot read property 'NullLogger' of undefined

时间:2021-02-18 17:51:29

使用angular cli新建组件

ng g component --flat -m mymodule mycomponent

报错:

Cannot read property 'NullLogger' of undefined
TypeError: Cannot read property 'NullLogger' of undefined
    at SchematicEngine.createContext (D:\Projects\demo\node_modules\@angular-devkit\schematics\src\engine\engine.js:64:38)
    at SchematicImpl.call (D:\Projects\demo\node_modules\@angular-devkit\schematics\src\engine\schematic.js:35:38)
    at Promise (D:\Projects\demo\node_modules\@angular\cli\tasks\schematic-run.js:72:23)
    at Class.run (D:\Projects\demo\node_modules\@angular\cli\tasks\schematic-run.js:71:16)
    at Class.run (D:\Projects\demo\node_modules\@angular\cli\commands\generate.js:149:33)
    at resolve (D:\Projects\demo\node_modules\@angular\cli\ember-cli\lib\models\command.js:261:20)
    at Class.validateAndRun (D:\Projects\demo\node_modules\@angular\cli\ember-cli\lib\models\command.js:240:12)
    at Promise.resolve.then.then (D:\Projects\demo\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:140:24)

Google了一下,很多通过重新安装angular cli可以解决此问题。

重新安装angular cli

npm uninstall -g angular-cli
npm cache clean --force
npm install -g @angular/cli@latest