ng generate service hero --module=app Error: Unknown argument: module
时间: 2024-02-20 11:57:30 浏览: 30
在较新版本的 Angular CLI 中,`--module`参数已被删除,因此在生成服务时不需要指定模块。
如果您想要在模块中注册服务,请手动打开该模块并将服务添加到providers数组中,例如:
```
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { HeroService } from './hero.service';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [
HeroService
],
bootstrap: [AppComponent]
})
export class AppModule { }
```
在上面的代码中,我们手动将HeroService服务添加到providers数组中以在AppModule中注册它。
然后,您可以使用以下命令生成服务:
```
ng generate service hero
```
这将在src/app目录下生成一个名为hero.service.ts的服务文件,并将其自动添加到providers数组中。
相关问题
arm-xilinx-linux-gnueabi-gcc: error: unrecognized command line option ‘-mrecord-mcount’; did you mean ‘-frecord-marker=4’?
This error message indicates that the compiler you are using (arm-xilinx-linux-gnueabi-gcc) does not recognize the command line option "-mrecord-mcount". It suggests that you may have meant to use "-frecord-marker=4" instead.
The "-mrecord-mcount" option is used to generate code that records function call counts, which can be used for profiling and optimization. However, this option may not be supported by all compilers or platforms.
If you need to use function call counting in your code, you may want to investigate alternative approaches that are supported by your compiler and platform. If you are not using function call counting, you can simply remove the "-mrecord-mcount" option from your build command.
typeorm-ts-node-commonjs migration:generate的完整指令
typeorm migration:generate --config ./ormconfig.js --name <你的迁移文件名> --typescript --transactional --connection <你的连接名> --config ./ormconfig.js --migrations-dir src/migrations --allow-no-extension --extension ts --formats commonjs
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)