Schematic "service/XXX" not found in collection "@schematics/angular".错误

华锦程
2023-12-01

当我要创建angular的service时报错

ng g service/services/storage

错误信息:

Your global Angular CLI version (8.3.6) is greater than your local
version (8.3.5). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".An unhandled exception occurred: Schematic "service/services/storage" not found in collection "@schematics/angular".
See "C:\Users\ASUS\AppData\Local\Temp\ng-FLG51S\angular-errors.log" for further details.

Baidu方法我查到

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

升级angular/cli。升级后确实没有再提醒我版本问题,但下面这个错误一直在:

An unhandled exception occurred: Schematic "service/services/storage" not found in collection "@schematics/angular".
See "C:\Users\ASUS\AppData\Local\Temp\ng-JfMclN\angular-errors.log" for further details.

也是觉得很神奇,去外国网站查资料一直说更新cli就ok.
脑壳疼。。。
最后的最后我终于发现原因了。。。。
代码写错了。。。
应该写成:
ng g service services/storage
而我写成:
ng g service/services/storage
感觉好像没错的样子,一直没发现。
写代码真的是一个要认真仔细的活。

 类似资料: