1

I am using Angular CLI to support multiple applications within one project.

"apps": [
{
  "name": "app1",
  "root": "src/app1",
  "outDir": "dist/app1",
  .
  .
},
{
  "name": "app2",
  "root": "src/app2",
  "outDir": "dist/app2",
  .
  .
}
]

But when I am running following command to generate a service

C:\POC\test1\src\app1\app>ng g service test --app=app1

Service is generated like this

create src/app1/src/app1/app/test.service.spec.ts (362 bytes)
create src/app1/src/app1/app/test.service.ts (110 bytes)

This is not correct. It should create like

create src/app1/app/test.service.spec.ts (362 bytes)
create src/app1/app/test.service.ts (110 bytes)

Am I doing something wrong?

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
  • Possible duplicate of [handling multiple applications with angular cli](https://stackoverflow.com/questions/45575372/handling-multiple-applications-with-angular-cli) – msanford Sep 27 '17 at 19:50
  • @msanford This question is specific to component/service/directive generation using Angular-cli when using multiple applications. It is not duplicate – Gaurav Kumar Sep 27 '17 at 19:54
  • What happens when you execute the command from the root directory (C:\POC\test1)? – JB Nizet Sep 27 '17 at 20:05
  • @JBNizet result is same from root directory as well – Gaurav Kumar Sep 27 '17 at 20:33
  • What CLI version do you use? And could you provide the whole angular-cli.json? Because your setting is working fine on my Angualr CLI test project. – jowey Sep 27 '17 at 21:11
  • @jowey I am using Angular CLI version 1.4.2 I am using VS Code & running the command in CMD terminal. Because of character limit in comment, I can not provide complete angular-cli.json – Gaurav Kumar Sep 27 '17 at 21:30
  • @GauravKumar, I'm trying to understand benefits of have more thank one app at a project. have your apps any relationship at runtime? if so, do you need "serve" them separated and using different ports? – Cristiano Nov 23 '17 at 17:02

1 Answers1

0

I would say you found a bug. Tested your setting on Angular CLI v.1.2.0 and v.1.3.2 both working fine, but at v.1.4.2 and latest v.1.4.3 I get the same behaviour.

Since the Angular CLI release notes of 1.4.x don't spot any significant changes I guess the behaviour is not intended. Maybe downgrade for a while or open a bug report.

EDIT: The problem was that Angular CLI hardcodes appRoot to app which causes the error. This was fixed with PR 7775.

jowey
  • 7,581
  • 6
  • 27
  • 46