ng生成服务地理定位时出错

时间:2018-01-19 06:50:36

标签: angular angular-services

我正在创建一个新项目,然后是一个新服务,我输入:

ng generate service Geolocation

但得到了一个错误:

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

我做了npm安装,但仍然没有成功,根据你来自哪里?

由于

3 个答案:

答案 0 :(得分:2)

您需要重新安装@angular/cli。请按照以下步骤操作:

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

答案 1 :(得分:0)

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

它对我有用

答案 2 :(得分:0)

我尝试使用npm install npm @ latest -g它现在完美无缺,谢谢大家:)